Example usage for java.lang.ref Reference clear

List of usage examples for java.lang.ref Reference clear

Introduction

In this page you can find the example usage for java.lang.ref Reference clear.

Prototype

public void clear() 

Source Link

Document

Clears this reference object.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    ReferenceQueue rq = new ReferenceQueue();
    PhantomReference<String> pr = new PhantomReference<String>("object", rq);

    while (true) {
        Reference r = rq.remove();
        if (r == pr) {
            // about to be reclaimed.
            r.clear();
        }/*  w ww  .j  a  v  a 2 s  .  co  m*/
    }
}