|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.gui.jmapviewer.JobDispatcher
public class JobDispatcher
A generic class that processes a list of Runnable
one-by-one using
one or more JobDispatcher.JobThread
-instances. The number of instances varies between
1 and WORKER_THREAD_MAX_COUNT
(default: 8). If an instance is idle
more than WORKER_THREAD_TIMEOUT
seconds (default: 30), the instance
ends itself.
Nested Class Summary | |
---|---|
protected class |
JobDispatcher.JobThread
|
Field Summary | |
---|---|
private static JobDispatcher |
instance
|
protected java.util.concurrent.BlockingQueue<java.lang.Runnable> |
jobQueue
|
private static java.util.logging.Logger |
log
|
static int |
WORKER_THREAD_MAX_COUNT
|
static int |
WORKER_THREAD_TIMEOUT
Specifies the time span in seconds that a worker thread waits for new jobs to perform. |
protected int |
workerThreadCount
Total number of worker threads currently idle or active |
protected int |
workerThreadId
Just an id for identifying an worker thread instance |
protected int |
workerThreadIdleCount
Number of worker threads currently idle |
Constructor Summary | |
---|---|
private |
JobDispatcher()
|
Method Summary | |
---|---|
void |
addJob(java.lang.Runnable job)
|
protected JobDispatcher.JobThread |
addWorkerThread()
|
void |
cancelOutstandingJobs()
Removes all jobs from the queue that are currently not being processed. |
static JobDispatcher |
getInstance()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.util.logging.Logger log
private static JobDispatcher instance
protected java.util.concurrent.BlockingQueue<java.lang.Runnable> jobQueue
public static int WORKER_THREAD_MAX_COUNT
public static int WORKER_THREAD_TIMEOUT
protected int workerThreadCount
protected int workerThreadIdleCount
protected int workerThreadId
Constructor Detail |
---|
private JobDispatcher()
Method Detail |
---|
public static JobDispatcher getInstance()
JobDispatcher
public void cancelOutstandingJobs()
public void addJob(java.lang.Runnable job)
protected JobDispatcher.JobThread addWorkerThread()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |