Code example for ReferenceQueue

0
        } 
    } 
 
    public static void main(String[] args) throws Exception {
        ThreadLocalKeyValue target = new ThreadLocalKeyValue();
        ReferenceQueue queue = new ReferenceQueue();
        PhantomReference ref = new PhantomReference(target, queue);
 
        target.add("foo", "bar");
        target = null;
 
        System.gc();
        System.out.println("Released?: " + ref.isEnqueued());
   } 
}