net.sourceforge.groboutils.util.thread.v1
Class LoopThread

java.lang.Object
  extended bynet.sourceforge.groboutils.util.thread.v1.LoopThread
Direct Known Subclasses:
QueueThread

public class LoopThread
extends java.lang.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.

Since:
June 4, 2000
Version:
$Date: 2003/02/10 22:52:48 $
Author:
Matt Albrecht groboclown@users.sourceforge.net

Field Summary
static long MILLI_IN_SECOND
           
 
Constructor Summary
LoopThread()
          Used in case the implementing class needs to postpone initialization until after the LoopThread construction.
LoopThread(java.lang.Runnable loop)
           
LoopThread(java.lang.Runnable loop, java.lang.String threadName)
           
LoopThread(java.lang.Runnable loop, java.lang.ThreadGroup group)
           
LoopThread(java.lang.Runnable loop, java.lang.ThreadGroup group, java.lang.String threadName)
           
 
Method Summary
 int getPriority()
           
 int getSleepTime()
          Retrieves the sleep time in seconds.
 long getSleepTimeMillis()
          Retrieves the sleep time in milliseconds.
 java.lang.ThreadGroup getThreadGroup()
           
 boolean isAlive()
           
 boolean isDaemon()
           
 boolean isPaused()
           
 boolean isRunning()
           
 void join()
           
 void resume()
           
 void setDaemon(boolean on)
           
 void setPriority(int priority)
           
 void setRunnable(java.lang.Runnable run)
          Sets the runnable instance after construction.
 void setSleepTime(int seconds)
          Sets the sleep time in seconds.
 void setSleepTimeMillis(long millis)
          Sets the sleep time in milliseconds.
 void start()
           
 void stop()
           
 void suspend()
          A non-deprecated, nice-to-the-system, thread suspension method.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MILLI_IN_SECOND

public static final long MILLI_IN_SECOND
See Also:
Constant Field Values
Constructor Detail

LoopThread

public LoopThread()
Used in case the implementing class needs to postpone initialization until after the LoopThread construction.


LoopThread

public LoopThread(java.lang.Runnable loop)

LoopThread

public LoopThread(java.lang.Runnable loop,
                  java.lang.String threadName)

LoopThread

public LoopThread(java.lang.Runnable loop,
                  java.lang.ThreadGroup group)

LoopThread

public LoopThread(java.lang.Runnable loop,
                  java.lang.ThreadGroup group,
                  java.lang.String threadName)
Method Detail

getPriority

public int getPriority()
See Also:
Thread.getPriority()

setPriority

public void setPriority(int priority)
See Also:
Thread.setPriority( int )

getThreadGroup

public java.lang.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 java.lang.InterruptedException
Throws:
java.lang.InterruptedException
See Also:
Thread.join()

setRunnable

public void setRunnable(java.lang.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 java.lang.String toString()
See Also:
Thread.toString()


Copyright © 2001-2003 by The GroboUtils Project