Code example for AtomicReference

Methods: compareAndSetget

0
/* 69 */   private final AtomicReference<T> reference = new AtomicReference();
/*    */  
/*    */   public T get() 
/*    */     throws ConcurrentException 
/*    */   { 
/* 81 */     Object result = this.reference.get();
/*    */  
/* 83 */     if (result == null) {
/* 84 */       result = initialize();
/* 85 */       if (!this.reference.compareAndSet(null, result))
/*    */       { 
/* 87 */         result = this.reference.get();
/*    */       } 
/*    */     } 
/*    */  
/* 91 */     return result;
/*    */   } 
/*    */  
/*    */   protected abstract T initialize() 
/*    */     throws ConcurrentException; 
Stop searching for code, let great code find you!  Add Codota to your java IDE