Code example for ReferenceQueue

Methods: sleep

0
             
            for (int i = 0; i < 4; i++) {
                Reference r = rq.remove(100L);
                assertNotNull("Reference should have been enqueued.", r);
            } 
 
            // These are to make sure that tprs and its elements don't get 
            // optimized out. 
            assertNull("get() should return null.", tprs[0].get());
            assertNull("get() should return null.", tprs[1].get());
            assertNull("get() should return null.", tprs[2].get());
            assertNull("get() should return null.", tprs[3].get());
        } catch (InterruptedException e) {
            fail("InterruptedException : " + e.getMessage());
        } 
    } 
 
    /** 
     * @tests java.lang.ref.PhantomReference#PhantomReference(java.lang.Object, 
     *        java.lang.ref.ReferenceQueue) 
     */