public class SequenceLock extends Object
| Constructor and Description |
|---|
SequenceLock() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
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.InterruptedExceptionpublic 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.
Copyright © 2004-2014. All Rights Reserved.