Slide 28
Slide 28 text
ReferenceQueue
ReferenceQueue queue = new ReferenceQueue();
for (int i = 0 ; i < 100 ; i++) {
WeakReference ref = new WeakReference(new Object(), queue);
for (int i = 0 ; i < 100 ; i++) {
WeakReference ref = new WeakReference(new Object(), queue);
Reference> r;
while ((r = queue.poll()) != null) { // polling to discover GC'ed referent
// reference 'r' cleared
}
}