|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.plt.concurrent.DelayedInterrupter
public class DelayedInterrupter
Sets a "time bomb" on a specific thread: if the abort() method is not invoked within a specified
amount of time (in milliseconds), the thread will be interrupted. In contrast to Object.wait(long),
implementing a timeout in this way clearly distinguishes between a timeout-triggered wake-up and a
Object.notify()-triggered or spurious wake-up. This alternative is also useful where the thread to
timeout performs multiple blocking operations, invokes blocking APIs that don't support timeouts
(like InputStream.read()), or polls for an interrupted state.
The timeout is implemented with a single Timer for all DelayedInterrupter instances. This
timer is a daemon: an outstanding DelayedInterrupter will not prevent the program from terminating.
| Constructor Summary | |
|---|---|
DelayedInterrupter(long timeToInterrupt)
Create an interrupter for the current thread. |
|
DelayedInterrupter(java.lang.Thread worker,
long timeToInterrupt)
Create an interrupter for the specified thread. |
|
| Method Summary | |
|---|---|
void |
abort()
Abort the request to interrupt the thread. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DelayedInterrupter(long timeToInterrupt)
timeToInterrupt - Number of milliseconds to allow an abort before the thread will be interrupted.
public DelayedInterrupter(java.lang.Thread worker,
long timeToInterrupt)
timeToInterrupt - Number of milliseconds to allow an abort before the thread will be interrupted.| Method Detail |
|---|
public void abort()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||