Code example for AtomicReference

Methods: compareAndSet

     * 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() { 
     * 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.