public abstract class DefaultRunnable
extends java.lang.Object
implements java.lang.Runnable
| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.locks.Lock |
lock
The lock protecting the runnable.
|
| Constructor and Description |
|---|
DefaultRunnable()
Creates a new instance with a fair reentrant lock.
|
DefaultRunnable(java.util.concurrent.locks.Lock lock)
Creates a new instance with the supplied lock.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
cancel()
An internal cancel method which ensures that if
this runnable is within a periodic schedule, it won't execute the next time.
|
boolean |
cancelled() |
protected abstract void |
onRun()
The alternative run method, which will be called by the original run() method under lock.
|
void |
run() |
protected final java.util.concurrent.locks.Lock lock
public DefaultRunnable()
public DefaultRunnable(@Nonnull
java.util.concurrent.locks.Lock lock)
lock - the lock objectpublic final void run()
run in interface java.lang.Runnablepublic boolean cancelled()
protected void cancel()
Note that this method throws a CancellationException which, when
propagated back to the scheduler pool, will disable the wrapper task.
Therefore, ensure that you do not accidentally catch this exception by a
catch (Throwable ex) clause.
protected abstract void onRun()