private static class TemporaryDirectory.CleanupShutdownHook
extends java.lang.Object
implements java.lang.Runnable
This class implements a task which will be run upon JVM shutdown. It contains a weak reference to the temporary directory object. This permits the temporary directory to be cleaned by the garbage collector as if the cleanup task did not exist. If the temporary directory object survives until JVM shutown, this task ensures that the temporary directory is removed.
Modifier and Type | Field and Description |
---|---|
private java.lang.ref.WeakReference<TemporaryDirectory> |
directory
A weak reference to the TemporaryDirectory object.
|
Constructor and Description |
---|
CleanupShutdownHook(TemporaryDirectory directory)
Creates and initializes the cleanup task.
|
Modifier and Type | Method and Description |
---|---|
void |
run()
Attempts to ensure that the directory is deleted when the virtual
machine exits.
|
private final java.lang.ref.WeakReference<TemporaryDirectory> directory
CleanupShutdownHook(TemporaryDirectory directory)
directory
- The temporary directory to be removed on JVM
shutdown, if not previously removed by a call to
remove
or finalize
.