Language

The Free and Open Productivity Suite
Released: Apache OpenOffice 4.1.15
OOoRunner test harness

util
Class WaitUnreachable

java.lang.Object
  |
  +--util.WaitUnreachable

public final class WaitUnreachable
extends Object

Wait until an object has become unreachable.

Instances of this class will typically be used as either:

   SomeType o = new SomeType(...);
   ... // use "o"
   WaitUnreachable u = new WaitUnreachable(o);
   o = null;
   u.waitUnreachable();
 

or:

   WaitUnreachable u = new WaitUnreachable(new SomeType(...));
   ... // use "(SomeType) u.get()"
   u.waitUnreachable();
 


Constructor Summary
WaitUnreachable(Object obj)
          Creates a new waiter.
 
Method Summary
static void ensureFinalization(Object obj)
          Ensures that an object will be finalized as soon as possible.
 Object get()
          Gets the object on which to wait.
 void waitUnreachable()
          Starts waiting for the object to become unreachable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WaitUnreachable

public WaitUnreachable(Object obj)
Creates a new waiter.
Parameters:
obj - the object on which to wait
Method Detail

get

public Object get()
Gets the object on which to wait.
Returns:
the object on which to wait, or null if waitUnreachable has already been called

waitUnreachable

public void waitUnreachable()
Starts waiting for the object to become unreachable.

This blocks the current thread until the object has become unreachable.

Actually, this method waits until the JVM has detected that the object has become unreachable. This is not deterministic, but this methods makes a best effort to cause the JVM to eventually detect the situation. With a typical JVM, this should suffice.


ensureFinalization

public static void ensureFinalization(Object obj)
Ensures that an object will be finalized as soon as possible.

This does not block the current thread. Instead, a new thread is spawned that busy waits for the given object to become unreachable.

This method cannot guarantee that the given object is eventually finalized, but it makes a best effort. With a typical JVM, this should suffice.

Parameters:
obj - the object of which to ensure finalization

OOoRunner test harness

Apache Software Foundation

Copyright & License | Privacy | Contact Us | Donate | Thanks

Apache, OpenOffice, OpenOffice.org and the seagull logo are registered trademarks of The Apache Software Foundation. The Apache feather logo is a trademark of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.