public class LoopingThread
extends java.lang.Thread
To use, either instantiate it with a Runnable object with a run() method that does what you want to do each time we loop, or alternately use an anonymous or subclass and override the runTask() method. Do not override run() on the LoopingThread; that method is what provides our looping behavior!
LoopingThreads are set as daemon threads by default (setDaemon(true)). You can set this to false in the usual manner (setDaemon(false)).
Copyright 2004-2009 Partner Software, Inc.
| Constructor and Description |
|---|
LoopingThread() |
LoopingThread(java.lang.String name) |
LoopingThread(java.lang.String name,
Duration interval) |
LoopingThread(java.lang.String name,
Duration interval,
java.lang.Runnable task) |
LoopingThread(java.lang.String name,
int interval) |
LoopingThread(java.lang.String name,
int interval,
java.lang.Runnable task) |
LoopingThread(java.lang.String name,
java.lang.Runnable task) |
| Modifier and Type | Method and Description |
|---|---|
int |
getInterval()
Gets the loop interval in milliseconds.
|
java.lang.Runnable |
getTask() |
boolean |
isRunning() |
void |
pauseLooping() |
void |
resumeLooping() |
void |
run() |
void |
runTask()
By default, this runs the runnable.
|
void |
setInterval(int newInterval)
Sets the loop interval in milliseconds.
|
void |
setTask(java.lang.Runnable newTask) |
void |
start() |
void |
stopRunning()
Tells the thread to quit looping.
|
activeCount, checkAccess, clone, 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, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yieldpublic LoopingThread()
public LoopingThread(java.lang.String name)
public LoopingThread(java.lang.String name,
java.lang.Runnable task)
public LoopingThread(java.lang.String name,
int interval)
public LoopingThread(java.lang.String name,
Duration interval)
public LoopingThread(java.lang.String name,
int interval,
java.lang.Runnable task)
public LoopingThread(java.lang.String name,
Duration interval,
java.lang.Runnable task)
public void pauseLooping()
public void resumeLooping()
public void start()
start in class java.lang.Threadpublic void run()
run in interface java.lang.Runnablerun in class java.lang.Threadpublic void runTask()
throws java.lang.Exception
java.lang.Exceptionpublic void stopRunning()
public void setInterval(int newInterval)
public int getInterval()
public void setTask(java.lang.Runnable newTask)
public java.lang.Runnable getTask()
public boolean isRunning()