Class CleanupRunnable
java.lang.Object
de.aristaflow.adept2.util.threading.CleanupRunnable
- All Implemented Interfaces:
Runnable
A cleanup runnable executes a runnable (or several ones) and afterwards a special cleanup
runnable finally after the first runnable. Problems occurring in the cleanup runnable will be
logged to the designated logger (and added as suppressed to problems of the runnable if
appropriate). This way exceptions from the first runnable will not be swallowed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final RunnableThe cleanup runnable executed after the normal execution has terminated.protected final LoggerThe logger for logging exceptions from the cleanup runnable.protected final RunnableThe runnable executed normally.protected final AtomicLongA count for concurrently executed runnables sharing a common resource cleaned up incleanup. -
Constructor Summary
ConstructorsConstructorDescriptionCleanupRunnable(Runnable runnable, Runnable cleanup, Logger logger) Creates a new cleanup runnable executing the first runnable and the cleanup runnable finally after the first runnable.CleanupRunnable(Runnable runnable, AtomicLong sharingCount, Runnable cleanup, Logger logger) Creates a new cleanup runnable executing the first runnable (and similar runnables concurrently) and the cleanup runnable finally right after the last of these runnables have terminated. -
Method Summary
-
Field Details
-
runnable
The runnable executed normally. -
sharingCount
-
cleanup
The cleanup runnable executed after the normal execution has terminated. -
logger
The logger for logging exceptions from the cleanup runnable.
-
-
Constructor Details
-
CleanupRunnable
Creates a new cleanup runnable executing the first runnable and the cleanup runnable finally after the first runnable. Problems occurring in the cleanup runnable will be logged to the designated logger.- Parameters:
runnable- The runnable executed normally.cleanup- The cleanup runnable executed after the normal execution has terminated.logger- The logger for logging exceptions from the cleanup runnable.
-
CleanupRunnable
Creates a new cleanup runnable executing the first runnable (and similar runnables concurrently) and the cleanup runnable finally right after the last of these runnables have terminated. Problems occurring in the cleanup runnable will be logged to the designated logger,RuntimeExceptions will be additionally added as suppressed to an exception of the first runnable if present.- Parameters:
runnable- The runnable executed normally.sharingCount- The count for synchronising similar runnables so thatcleanupwill not run before all runnables have terminated.cleanup- The cleanup runnable executed after the designated runnables (and similar ones) have terminated.logger- The logger for logging exceptions from the cleanup runnable.
-
-
Method Details