|
jMobileCore toolkit | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
com.jmobilecore.thread.AdvThread
public class AdvThread
This class implements scheduling mechanism for repeatable task execution You can specify frequency of execution and delay before first start. Also you can temporaryly stop and resume task execution or manually run the specified task
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
protected int |
delay
The delay (in milliseconds) before first execution of current task |
protected boolean |
forcedRun
Indicates if current task is forces to run |
protected int |
frequency
The frequency (in milliseconds) of repeatable task execution |
protected boolean |
isActive
Indicates if current thread is in active phase |
protected boolean |
reset
Indicates if the frequency was reset |
java.lang.Runnable |
task
The task for current threas |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
AdvThread(java.lang.Runnable task)
Creates a new AdvThread instance for specified task. |
|
AdvThread(java.lang.Runnable task,
int frequency)
Creates a new AdvThread instance for specified task
and specifies frequency for repeatable execution. |
Method Summary | |
---|---|
protected void |
destructor()
Default destructor. |
void |
run()
Overrides standard run method of Thread class This methods works as scheduler for Runnable task execution |
boolean |
runOnce()
Manual execution of task If task is running then it will continue to run, when completed no other executions will happen Next task launch is not affected unless task execution is not completed at the time of scheduled launch At this case next task launch is skipped |
boolean |
setFrequency(int frequency)
Set frequency for automatic execution of thread |
boolean |
setFrequency(int frequency,
int delay)
Set frequency for automatic execution of thread |
boolean |
terminate()
Terminates thread processing If task is running then it will continue to run, when completed no other executions will happen if task is scheduled for execution, it will be cancelled |
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, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected volatile int delay
protected volatile boolean forcedRun
runOnce()
protected volatile int frequency
task
protected volatile boolean isActive
protected volatile boolean reset
setFrequency(int frequency)
,
setFrequency(int frequency, int delay)
public java.lang.Runnable task
Constructor Detail |
---|
public AdvThread(java.lang.Runnable task)
AdvThread
instance for specified task.
task
- The Runnable object containing task implementation.
Task can be scheduled for repeatable or single tame execution laterpublic AdvThread(java.lang.Runnable task, int frequency)
AdvThread
instance for specified task
and specifies frequency for repeatable execution.
task
- The Runnable object containing task implementation.frequency
- The frequency in milliseconds for repetable task execution
Frequency should be non-negative integer, ignored otherwise
If frequency is zero then automatic execution is deisabled, task could be excecuted by runOnce method onlyMethod Detail |
---|
protected void destructor()
public void run()
Runnable task
execution
run
in interface java.lang.Runnable
run
in class java.lang.Thread
task
public boolean runOnce()
public boolean setFrequency(int frequency)
frequency
- The frequency in milliseconds for repeatable task execution
If frequency is zero then automatic execution is deisabled, task could be excecuted by runOnce method only
First execution of task will happen after frequency delaypublic boolean setFrequency(int frequency, int delay)
frequency
- The frequency in milliseconds for repeatable task execution
If frequency is zero then automatic execution is deisabled, task could be excecuted by runOnce method only
First execution of task will happen after frequency delaydelay
- The delay in milliseconds of first task executionpublic boolean terminate()
|
jMobileCore toolkit | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |