Code example for AtomicReference

Methods: compareAndSet

0
  public void bind(TransportCallback callback) throws IOException {
    if (callback == null) {
      throw new NullPointerException("callback");
    } 
     
    if (!callbackRef.compareAndSet(null, callback)) {
      throw new IOException();
    } 
  } 
   
  @Override 
  public void unbind() { 
    callbackRef.set(null);
  } 
 
  @Override 
  public boolean isBound() { 
    return callbackRef.get() != null;
  } 
   
  /**