Package org.mycore.util.concurrent
Class MCRDelayedRunnable
java.lang.Object
org.mycore.util.concurrent.MCRDelayedRunnable
- All Implemented Interfaces:
Comparable<Delayed>
,Runnable
,Delayed
,MCRDecorator<Runnable>
Encapsulates a
Runnable
with in a object that can be fed into a
DelayQueue
Note: This class has a natural ordering that is inconsistent with equals.
Note: Two objects of this class are equal, if their ids are equal
(other properties are ignored).- Author:
- Robert Stephan
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMCRDelayedRunnable
(String id, long delayInMs, Runnable runnable) Creates a newMCRDelayedRunnable
encapsulating a Runnable for delayed execution. -
Method Summary
-
Field Details
-
runnable
-
-
Constructor Details
-
MCRDelayedRunnable
Creates a newMCRDelayedRunnable
encapsulating a Runnable for delayed execution.- Parameters:
id
- , - the id of the runnable (used for equals-check)delayInMs
- - the time in (ms) the task should be delayedrunnable
- the runnable to execute within a session and transaction
-
-
Method Details
-
run
public void run() -
get
Description copied from interface:MCRDecorator
Returns the enclosing instance.- Specified by:
get
in interfaceMCRDecorator<Runnable>
- Returns:
- the decorated instance
-
getId
-
compareTo
order objects by their startTime- Specified by:
compareTo
in interfaceComparable<Delayed>
-
getDelay
-
hashCode
public int hashCode() -
equals
two objects are equal, if they have the same id
-