Code examples for PhantomReference

Codota analyzed 7,668,838 open source code samples to find the most common, credible and clear examples.
You can now enable Codota on your own code to easily search and navigate your Java codebase.
41:	PhantomReference pr = new PhantomReference(bool, rq); 
42:	assertNull("get() should return null.", pr.get()); 
43:	pr.enqueue(); 
44:	assertNull("get() should return null.", pr.get()); 
45:	pr.clear(); 
46:	assertNull("get() should return null.", pr.get()); 
Full Snippet Info
6
CodeRank
47:	PhantomReference pr = new PhantomReference(bool, rq); 
-
49:	Thread.sleep(1000); 
50:	assertTrue("Initialization failed.", !pr.isEnqueued()); 
Full Snippet Info
6
CodeRank
177:	PhantomReference pr = new PhantomReference(str, rq); 
-
179:	pr.enqueue(); 
-
211:	Thread.sleep(10); 
-
217:	Thread.sleep(10); 
Full Snippet Info
6
CodeRank
31:	cleanupRef.clear(); 
32:	cleanupRef.enqueue(); 
Full Snippet Info
5
CodeRank
37:	reference = new PhantomReference(object, referenceQueue); 
-
41:	System.out.println(reference.get()); // null 
-
43:	System.out.println(reference.isEnqueued()); // false 
-
46:	System.out.println(reference.get()); // null 
-
48:	System.out.println(reference.isEnqueued()); // false 
-
54:	System.out.println(reference.get()); // null 
-
56:	System.out.println(reference.isEnqueued()); // true, because object has 
Full Snippet Info
5
CodeRank
168:	cleanupRef.clear(); 
169:	cleanupRef.enqueue(); 
Full Snippet Info
5
CodeRank
47:	PhantomReference pr = new PhantomReference(bool, rq); 
-
49:	Thread.sleep(1000); 
50:	assertTrue("Initialization failed.", !pr.isEnqueued()); 
Full Snippet Info
5
CodeRank
34:	PhantomReference ref = new PhantomReference(target, queue); 
-
40:	System.out.println("Released?: " + ref.isEnqueued()); 
Full Snippet Info
5
CodeRank
177:	PhantomReference pr = new PhantomReference(str, rq); 
-
179:	pr.enqueue(); 
-
211:	Thread.sleep(10); 
-
217:	Thread.sleep(10); 
Full Snippet Info
5
CodeRank
177:	PhantomReference pr = new PhantomReference(str, rq); 
-
179:	pr.enqueue(); 
-
211:	Thread.sleep(10); 
-
217:	Thread.sleep(10); 
Full Snippet Info
5
CodeRank
69:	mCleanup.put(new PhantomReference<NativeAESCipherSpi>(ref, mQueue), ptr); 
Full Snippet Info
5
CodeRank
156:	cleanupRef.clear(); 
157:	cleanupRef.enqueue(); 
Full Snippet Info
4
CodeRank
83:	PhantomReference<Object> phantomRef = new PhantomReference<Object>(new Object(), queue); 
-
100:	Thread.sleep(2000); 
Full Snippet Info
4
CodeRank
86:	PhantomReference<Stuff> phantomS = new PhantomReference<Stuff>(instantiateStuff("Phantom Reachable"), queue); 
-
107:	Thread.sleep(2000); 
Full Snippet Info
4
CodeRank
31:	cleanupRef.clear(); 
32:	cleanupRef.enqueue(); 
Full Snippet Info
5
CodeRank
93:	PhantomReference pr = new PhantomReference(tmpC, new ReferenceQueue()); 
-
96:	assertNull("Referent is not null.", pr.get()); 
-
99:	pr.clear(); 
-
102:	assertNull("Referent is not null.", pr.get()); 
Full Snippet Info
5
CodeRank
19:	PhantomReference<Object> phantomReference = new PhantomReference<>(object, referenceQueue); 
-
21:	assertNull(phantomReference.get()); 
-
26:	assertNull(phantomReference.get()); 
Full Snippet Info
5
CodeRank
17:	PhantomReference<Person> pr = new PhantomReference<Person>(person, rq); 
-
22:	System.out.println(pr.get()); 
Full Snippet Info
5
CodeRank
15:	PhantomReference<Person> pr = new PhantomReference<Person>(person, rq); 
-
20:	System.out.println(pr.get()); 
Full Snippet Info
5
CodeRank
72:	REFERENCES.remove(ref); 
73:	ref.clear(); 
Full Snippet Info
5
CodeRank