|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread game.net.StoppableThread
public class StoppableThread
A Thread you can stop gracefully. Remember nullify references to the thread after you are finished. Threads are big. You can't restart it! version 1.0 2002-08-01 version 1.1 2002-08-02 Make pleaseStop volatile and synchronize access to it. Required for multi-cpu cache synchronization.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
StoppableThread(java.lang.Runnable r)
Constructor. |
Method Summary | |
---|---|
void |
gentleStop(boolean interrupt,
long timeout)
Stop this thread gracefully. |
void |
start()
Start this thread executing its run method on a separate thread. |
boolean |
stopping()
this.run should call stopping() at convenient invervals to see if it has been requested to stop. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public StoppableThread(java.lang.Runnable r)
r
- Class that has a run methodMethod Detail |
---|
public void gentleStop(boolean interrupt, long timeout)
interrupt
- true if this thread should be interrupted from sleep or from doing
an i/o (which might close the channel), before stopping it.timeout
- How long in milliseconds to wait for the thread to die before
giving up. 0 means wait forever. -1 means don't wait at all.public void start()
start
in class java.lang.Thread
java.lang.IllegalThreadStateException
- if this thread is already started.public final boolean stopping()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |