Package com.intergral.deep.agent.poll
Class DriftAwareThread
- java.lang.Object
-
- java.lang.Thread
-
- com.intergral.deep.agent.poll.DriftAwareThread
-
- All Implemented Interfaces:
Runnable
public class DriftAwareThread extends Thread
A thread that can run aITimerTask
accounting for drifting time.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description DriftAwareThread(String name, ITimerTask runnable, long interval)
Create a new thread.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected long
checkForEarlyWake(long now, long nextExecutionTime)
void
run()
void
start(long delay)
Start the thread using the provided delay.protected long
whatIsNextExecutionTime(long executionTime, long now)
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Constructor Detail
-
DriftAwareThread
public DriftAwareThread(String name, ITimerTask runnable, long interval)
Create a new thread.- Parameters:
name
- the name for the threadrunnable
- theITimerTask
to executeinterval
- the interval in ms between each execution
-
-
Method Detail
-
start
public void start(long delay)
Start the thread using the provided delay.- Parameters:
delay
- a delay in ms
-
whatIsNextExecutionTime
protected long whatIsNextExecutionTime(long executionTime, long now)
-
checkForEarlyWake
protected long checkForEarlyWake(long now, long nextExecutionTime) throws InterruptedException
- Throws:
InterruptedException
-
-