public abstract class TimedThread
extends java.lang.Thread
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()
;
Modifier and Type | Method and Description |
---|---|
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.
|
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
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