TimedThread
Date: 2014-01-09

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.gcube.vremanagement.resourcebroker.impl.support.threads
Class TimedThread

    java.lang.Object
      java.lang.Thread
          org.gcube.vremanagement.resourcebroker.impl.support.threads.TimedThread

All Implemented Interfaces:
  java.lang.Runnable

Direct Known Subclasses:
  TPersistentResourceRefresh, TRevokeReservations, TUpdateGHNProfiles

    public abstract class TimedThread

extends java.lang.Thread

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 = new TimedThread(2000) {
            //@Override
            public void loop() {
                    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();

Author:
  Daniele Strollo (ISTI-CNR)

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

### loop

    public abstract void loop()

  The main loop that must be defined.

### run

    public final void run()

  Deprecated. Do not use this. For internal use only.

  Specified by:
    `run` in interface `java.lang.Runnable`
  Overrides:
    `run` in class `java.lang.Thread`

### interrupt

    public final void interrupt()

  Deprecated. Do not use this. For internal use only. Use `TimedThreadsStorage` instead.

  Overrides:
    `interrupt` in class `java.lang.Thread`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD