|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
org.gcube.vremanagement.resourcebroker.impl.support.threads.TimedThread
public abstract class TimedThread
A general purpose Scheduled Thread.
At creation time receives the delay slot (in mills)
the main loop must wait before being executed.
All implementing classes must simply define
the loop logics to execute without considering the
scheduling strategy and regardless the mechanisms to
stop the thread.
An intermediate component TimedThreadsStorage
is demanded to register all instances of these thread
and to properly interrupt them at shutdown phase.
Usage:TimedThread
t1 = newTimedThread
(2000) { //@Override public voidloop()
{ System.out.println("I'm a thread sleeping 2 seconds"); // That's my code.... } };
Shutdown management: // When registered it is required to startup the thread implicitly // otherwise it can be explicitly started through // t1.start()TimedThreadsStorage.registerThread(org.gcube.vremanagement.resourcebroker.impl.support.threads.TimedThread)
(t1, true); // ... // Once a shutdown is required it is enough to invoke:TimedThreadsStorage.stopAll()
;
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 |
Method Summary | |
---|---|
void |
interrupt()
Deprecated. Do not use this. For internal use only. Use TimedThreadsStorage instead. |
abstract void |
loop()
The main loop that must be defined. |
void |
run()
Deprecated. Do not use this. For internal use only. |
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, 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 |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public abstract void loop()
public final void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public final void interrupt()
TimedThreadsStorage
instead.
interrupt
in class java.lang.Thread
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |