|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jvnet.hudson.test.SequenceLock
public class SequenceLock
Lock mechanism to let multiple threads execute phases sequentially.
Constructor Summary | |
---|---|
SequenceLock()
|
Method Summary | |
---|---|
void |
abort()
Tell all the threads that this sequencing was aborted. |
void |
done()
Marks the current phase completed that the calling thread was executing. |
void |
phase(int i)
Blocks until all the previous phases are completed, and returns when the specified phase i is started. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SequenceLock()
Method Detail |
---|
public void phase(int i) throws InterruptedException
IllegalStateException
- if the sequential lock protocol is aborted, or the thread that owns the current phase has quit.
InterruptedException
public void done()
This is only necessary when the thread exits the last phase, as phase(int)
call implies the
done()
call.
public void abort()
Calling this method from the finally block prevents a dead lock if one of the participating thread aborts with an exception, as without the explicit abort operation, other threads will block forever for a phase that'll never come.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |