Code example for AtomicReference

0
  private final ArrayBlockingQueue<T> holder;
 
  public SingleEntryAsyncQueue(long timeoutInSecs) {
    timeoutInSeconds = timeoutInSecs;
    holder = new ArrayBlockingQueue<T>(1);
    poisonData = new AtomicReference<T>();
  } 
 
  public long getTimeoutInSeconds() { 
    return timeoutInSeconds;
  } 
 
  protected void setPoison(T poisonInstance) {
    poisonData.set(poisonInstance);
  } 
 
  protected boolean isPoison(T poisonSample) {
    T poison = poisonData.get();
    return null != poison && poison.equals(poisonSample);
  } 
Connect your IDE to all the code out there  Get Codota for Java