- All Implemented Interfaces:
Runnable
public abstract class SelfCleaningRunnable
extends Object
implements Runnable
A wrapper for Runnables that provides a hook to do cleanup.
-
Constructor Summary
Constructors
-
Method Summary
protected abstract void
void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
SelfCleaningRunnable
public SelfCleaningRunnable(Runnable runnable)
Constructor.
- Parameters:
runnable
- the Runnable to wrap
-
Method Details
-
run
public void run()
- Specified by:
run
in interface Runnable
-
cleanup
protected abstract void cleanup()
Cleanup.
Derived classes should put any necessary cleanup in here. This
is guaranteed to be called, even if the wrapped Runnable throws an
exception.