Code example for PhantomReference

Methods: get

0
	 * @tests java.lang.ref.PhantomReference#get() 
	 */ 
	public void test_get() { 
		ReferenceQueue rq = new ReferenceQueue();
		bool = new Boolean(false);
		PhantomReference pr = new PhantomReference(bool, rq);
		assertNull("Same object returned.", pr.get());
	} 
 
	/** 
	 * @tests java.lang.ref.PhantomReference#PhantomReference(java.lang.Object, 
	 *        java.lang.ref.ReferenceQueue) 
	 */ 
	public void test_ConstructorLjava_lang_ObjectLjava_lang_ref_ReferenceQueue() throws Exception { 
		ReferenceQueue rq = new ReferenceQueue();
		bool = new Boolean(true);
                PhantomReference pr = new PhantomReference(bool, rq);
                // Allow the finalizer to run to potentially enqueue 
                Thread.sleep(1000);
                assertTrue("Initialization failed.", !pr.isEnqueued());
Connect your IDE to all the code out there  Get Codota for Java