All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Acme.TimeKiller

java.lang.Object
   |
   +----Acme.TimeKiller

public class TimeKiller
extends Object
implements Runnable
Kill a thread after a given timeout has elapsed

A simple timeout class. You give it a thread to watch and a timeout in milliseconds. After the timeout has elapsed, the thread is killed with a Thread.stop(). If the thread finishes successfully before then, you can cancel the timeout with a done() call; you can also re-use the timeout on the same thread with the reset() call.

Fetch the software.
Fetch the entire Acme package.


Constructor Index

 o TimeKiller(long)
Constructor, current thread.
 o TimeKiller(Thread, long)
Constructor.

Method Index

 o done()
Call this when the target thread has finished.
 o reset()
Call this to restart the wait from zero.
 o reset(long)
Call this to restart the wait from zero with a different timeout value.
 o run()
The watcher thread - from the Runnable interface.

Constructors

 o TimeKiller
 public TimeKiller(Thread targetThread,
                   long millis)
Constructor. Give it a thread to watch, and a timeout in milliseconds. After the timeout has elapsed, the thread gets killed. If you want to cancel the kill, just call done().

 o TimeKiller
 public TimeKiller(long millis)
Constructor, current thread.

Methods

 o done
 public synchronized void done()
Call this when the target thread has finished.

 o reset
 public synchronized void reset()
Call this to restart the wait from zero.

 o reset
 public synchronized void reset(long millis)
Call this to restart the wait from zero with a different timeout value.

 o run
 public synchronized void run()
The watcher thread - from the Runnable interface. This has to be pretty anal to avoid monitor lockup, lost threads, etc.


All Packages  Class Hierarchy  This Package  Previous  Next  Index

ACME Java  ACME Labs