public boolean clear(T expect,boolean allowReset){
  sync.lock();
  try {
    if (expect != value) {
      return false;
    }
    ValueState prev=state;
    clear(allowReset);
    return prev == ValueState.SET;
  }
  finally {
    sync.unlock();
  }
}

public boolean clear ( T expect , boolean allowReset ) { sync . lock ( ) ; try { if ( expect != value ) { return false ; } ValueState prev = state ; clear ( allowReset ) ; return prev == ValueState . SET ; } finally { sync . unlock ( ) ; } }
clears the cached value as long it matches the expected value .
