Top Description Inners Fields Constructors Methods
com.sun.star.lib.util

public final Class AsynchronousFinalizer

extends Object
Class Inheritance
Imports
java.util.LinkedList

Helper class to asynchronously execute finalize methods.

Current JVMs seem not to be robust against long-running finalize methods, in that such long-running finalize methods may lead to OutOfMemoryErrors. This class mitigates the problem by asynchronously shifting the bodies of potentially long-running finalize methods into an extra thread. Classes that make use of this in their finalize methods are the proxies used in the intra-process JNI UNO bridge and the inter-process Java URP UNO bridge (where in both cases finalizers lead to synchronous UNO release calls).

Irrespective whether JVMs are getting more mature and should no longer have problems with long-running finalize methods, at least the JNI UNO bridge needs some way to stop finalization of proxies (to C++ objects) well before process exit, as provided by drain().

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
AsynchronousFinalizer.Job

An interface to represent bodies of finalize methods.

Field Summary

Modifier and TypeField and Description
private boolean
private final LinkedList<AsynchronousFinalizer.Job>
private final Thread

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(AsynchronousFinalizer.Job
represents the body of some finalize method; must not be null.
job
)

Add a job to be executed asynchronously.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

doneback to summary
private boolean done
queueback to summary
private final LinkedList<AsynchronousFinalizer.Job> queue
threadback to summary
private final Thread thread

Constructor Detail

AsynchronousFinalizerback to summary
public AsynchronousFinalizer()

Method Detail

addback to summary
public void add(AsynchronousFinalizer.Job job)

Add a job to be executed asynchronously.

The run method of the given job is called exactly once. If it terminates abnormally by throwing any Throwable, that is ignored.

Parameters
job:AsynchronousFinalizer.Job

represents the body of some finalize method; must not be null.

drainback to summary
public void drain() throws InterruptedException
com.sun.star.lib.util back to summary

public Interface AsynchronousFinalizer.Job


An interface to represent bodies of finalize methods. Similar to Runnable, except that the run method may throw any Throwable (which is effectively ignored by AsynchronousFinalizer.add, similar to any Throwables raised by finalize being ignored).

Method Summary

Modifier and TypeMethod and Description
public void
run()

Method Detail

runback to summary
public void run() throws Throwable