Code example for AtomicReference

Methods: compareAndSet

0
     * harness thread, triggering a test case failure.  Only the first 
     * failure is recorded; subsequent calls to this method from within 
     * the same test have no effect. 
     */ 
    public void threadRecordFailure(Throwable t) {
        threadFailure.compareAndSet(null, t);
    } 
 
    public void setUp() { 
        setDelays(); 
    } 
 
    /** 
     * Extra checks that get done for all test cases. 
     * 
     * Triggers test case failure if any thread assertions have failed, 
     * by rethrowing, in the test harness thread, any exception recorded 
     * earlier by threadRecordFailure. 
     * 
     * Triggers test case failure if interrupt status is set in the main thread. 
     */