- All Implemented Interfaces:
- Direct Known Subclasses:
- AgentBase, AgentSystem, ServingThread
- public abstract class CancellableThread
- extends Thread
A thread which can be cancelled by another thread. If it does not want to die, its priority
is set to a minimum (
Thread.stop() is deprecated).
- 1.0, 1.7.2000
- Michael Sonntag
Cancel this thread.
true if this thread-object (not the current thread!)
Main method of the thread.
Cancels this tread and wait till it has stopped (or it is impossible).
|Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
public void cancel()
- Cancel this thread. Will try to stop it, but returns immediately.
public boolean isCancelled()
true if this thread-object (not the current thread!) is cancelled.
- if this thread is cancelled
public boolean terminate(long maxWaitToDie)
- Cancels this tread and wait till it has stopped (or it is impossible).
Will wait for a number of seconds or indefinitely (called with 0).
If called from within the thread a
ThreadDeath error will be thrown
if it dies not gracefully.
maxWaitToDie - number of seconds to wait for the thread to stop gracefully
true if the thread is stopped (false: continues to run)
public abstract void run()
- Main method of the thread. Subclasses must override and place funtion in here.
Any subclasses should regularly check if this thread is cancelled, especially
wait was interrupted.
run in class
Submit a bug
Copyright 2001,2002 Michael Sonntag & Institute for Information Processing and Microprocessor Technology (FIM), Johannes-Kepler-University Linz, Altenbergerstr. 69, A-4040 Linz, Austria.