net.groboclown.util.thread.v1
Class LoopThread
java.lang.Object
|
+--net.groboclown.util.thread.v1.LoopThread
- Direct Known Subclasses:
- QueueThread
- public class LoopThread
- extends Object
For threads which loop endlessly (which is a common thing), this
class implements the pause, start, and stop routines since JDK 1.2
deprecated theirs.
This class delegates the Thread object, so that this class doesn't
have to emulate all those thread methods. In this way, a LoopThread
should act just like a Thread.
- Version:
- Alpha 0.9.0
- Author:
- Matt Albrecht
Inner Class Summary |
private class |
LoopThread.LoopRunnable
The runnable class - keep it private so no one
can directly access it in a thread but us. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait |
MILLI_IN_SECOND
public static final long MILLI_IN_SECOND
tryPause
private boolean tryPause
tryStop
private boolean tryStop
isPaused
private boolean isPaused
isRunning
private boolean isRunning
pauseObject
private Object pauseObject
sleepTime
private long sleepTime
thisThread
private Thread thisThread
runnable
private Runnable runnable
LoopThread
public LoopThread()
- Used in case the implementing class needs to postpone initialization
until after the LoopThread construction.
LoopThread
public LoopThread(Runnable loop)
LoopThread
public LoopThread(Runnable loop,
String threadName)
LoopThread
public LoopThread(Runnable loop,
ThreadGroup group)
LoopThread
public LoopThread(Runnable loop,
ThreadGroup group,
String threadName)
getPriority
public int getPriority()
- See Also:
Thread.getPriority()
setPriority
public void setPriority(int priority)
- See Also:
Thread.setPriority( int )
getThreadGroup
public ThreadGroup getThreadGroup()
- See Also:
Thread.getThreadGroup()
isAlive
public boolean isAlive()
- See Also:
Thread.isAlive()
isDaemon
public boolean isDaemon()
- See Also:
Thread.isDaemon()
setDaemon
public void setDaemon(boolean on)
- See Also:
Thread.setDaemon( boolean )
join
public void join()
throws InterruptedException
- See Also:
Thread.join()
setRunnable
public void setRunnable(Runnable run)
- Sets the runnable instance after construction. It cannot be
changed once the thread is running.
start
public void start()
- See Also:
Thread.start()
suspend
public void suspend()
- A non-deprecated, nice-to-the-system, thread suspension method.
- See Also:
Thread.suspend()
resume
public void resume()
- See Also:
Thread.resume()
stop
public void stop()
- See Also:
Thread.stop()
isPaused
public boolean isPaused()
isRunning
public boolean isRunning()
getSleepTime
public int getSleepTime()
- Retrieves the sleep time in seconds.
setSleepTime
public void setSleepTime(int seconds)
- Sets the sleep time in seconds.
setSleepTimeMillis
public void setSleepTimeMillis(long millis)
- Sets the sleep time in milliseconds.
getSleepTimeMillis
public long getSleepTimeMillis()
- Retrieves the sleep time in milliseconds.
toString
public String toString()
- Overrides:
toString
in class Object
- See Also:
Thread.toString()
Written under the LGPL