Package org.cip4.jdflib.util.thread
Class OrderedTaskQueue
java.lang.Object
java.lang.Thread
org.cip4.jdflib.util.thread.OrderedTaskQueue
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
MultiTaskQueue
class to run heavy tasks one at a 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 -
Method Summary
Modifier and TypeMethodDescriptionintlongGetter for average time waitinglonggetAvRun()Getter for average time runningstatic OrderedTaskQueuegetCreateQueue(String name) grab the queueintgetDone()number of already completed taskslongGetter for sumQueue attribute.longGetter for sumRun attribute.booleaninterruptCurrent(int minAge) booleanisLive()booleanvoidrun()voidshutDown()static voidgrab the queuestatic voidintsize()size of the waiting queuetoString()intwaiting()size of the waiting queue + currently executingMethods 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, yield
-
Method Details
-
getCreateQueue
grab the queue- Parameters:
name- - must not be null- Returns:
- the queue to fill with tasks
-
shutDown
grab the queue- Parameters:
name- - must not be null
-
shutDownAll
public static void shutDownAll() -
shutDown
public void shutDown() -
interruptCurrent
public boolean interruptCurrent(int minAge) - Parameters:
minAge- minimum age to interrupt- Returns:
- true if we successfully interrupted or no entry was running; false if unsuccessful or current is younger than minAge
-
size
public int size()size of the waiting queue- Returns:
-
executing
public int executing() -
waiting
public int waiting()size of the waiting queue + currently executing- Returns:
-
getDone
public int getDone()number of already completed tasks- Returns:
-
isLive
public boolean isLive()- Returns:
-
queue
- Parameters:
task- the thing to send off- Returns:
- true if successfully queued
-
run
public void run() -
toString
-
shortString
-
getAvQueue
public long getAvQueue()Getter for average time waiting- Returns:
- the average sumQueue
-
getSumQueue
public long getSumQueue()Getter for sumQueue attribute. total time waiting- Returns:
- the sumQueue
-
getAvRun
public long getAvRun()Getter for average time running- Returns:
- the average sumRun
-
getSumRun
public long getSumRun()Getter for sumRun attribute. total time running- Returns:
- the sumRun
-