Code example for ReferenceQueue

Methods: poll

0
		// store in a static so it won't be gc'ed because the jit 
		// optimized it out 
		b = new Boolean(true);
		SoftReference sr = new SoftReference(b, rq);
		sr.enqueue();
                assertTrue("Remove failed.", ((Boolean) rq.poll().get())
                                .booleanValue());
	} 
 
	/** 
	 * @tests java.lang.ref.ReferenceQueue#remove() 
	 */ 
	public void test_remove() throws Exception { 
		// store in a static so it won't be gc'ed because the jit 
		// optimized it out 
		b = new Boolean(true);
		SoftReference sr = new SoftReference(b, rq);
		sr.enqueue();
                assertTrue("Remove failed.", ((Boolean) rq.remove().get())
                                .booleanValue());
	}