public class BlockingTestRunnable extends TestRunnable
TestRunnable
which will initially block the running thread with
Object.wait()
when handleRunStart()
is invoked. The thread will remain blocked
until unblock()
is invoked.Constructor and Description |
---|
BlockingTestRunnable() |
Modifier and Type | Method and Description |
---|---|
void |
handleRunStart()
Function to be overloaded by extending classes if more data or operations need to happen at
the run point.
|
boolean |
isUnblocked()
Check if the task has been unblocked yet.
|
void |
unblock()
Invoke to unblock any current or future executions for this
TestRunnable . |
blockTillFinished, blockTillFinished, blockTillFinished, blockTillStarted, blockTillStarted, getCreationTime, getDelayTillFirstRun, getDelayTillRun, getDelayTillRun, getRunCount, getRunDelayInMillis, handleRunFinish, isRunning, ranConcurrently, ranOnce, run, setRunDelayInMillis
public void handleRunStart() throws java.lang.InterruptedException
TestRunnable
This is also the first call to be made in the runnable, but all necessary
TestRunnable
actions are in a finally block so it is safe to throw any exceptions
necessary here.
handleRunStart
in class TestRunnable
java.lang.InterruptedException
- only InterruptedExceptions will be swallowedpublic boolean isUnblocked()
true
if the thread has been unblocked.public void unblock()
TestRunnable
. Once invoked
no future blocking will occur. In general this should be invoked at the end of every test
(fail or not) to avoid having left over blocked threads hanging around.