Package org.cip4.jdflib.util.thread
Class OrderedTaskQueue
- java.lang.Object
-
- java.lang.Thread
-
- org.cip4.jdflib.util.thread.OrderedTaskQueue
-
- All Implemented Interfaces:
java.lang.Runnable
- Direct Known Subclasses:
MultiTaskQueue
public class OrderedTaskQueue extends java.lang.Threadclass to run heavy tasks one at a time
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intexecuting()longgetAvQueue()Getter for average time waitinglonggetAvRun()Getter for average time runningstatic OrderedTaskQueuegetCreateQueue(java.lang.String name)grab the queueintgetDone()number of already completed taskslonggetSumQueue()Getter for sumQueue attribute.longgetSumRun()Getter for sumRun attribute.booleaninterruptCurrent(int minAge)booleanisLive()booleanqueue(java.lang.Runnable task)voidrun()java.lang.StringshortString()voidshutDown()static voidshutDown(java.lang.String name)grab the queuestatic voidshutDownAll()intsize()size of the waiting queuejava.lang.StringtoString()intwaiting()size of the waiting queue + currently executing-
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, yield
-
-
-
-
Method Detail
-
getCreateQueue
public static OrderedTaskQueue getCreateQueue(java.lang.String name)
grab the queue- Parameters:
name- - must not be null- Returns:
- the queue to fill with tasks
-
shutDown
public static void shutDown(java.lang.String name)
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
public boolean queue(java.lang.Runnable task)
- Parameters:
task- the thing to send off- Returns:
- true if successfully queued
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread- See Also:
Thread.run()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Thread- Returns:
- See Also:
Thread.toString()
-
shortString
public java.lang.String 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
-
-