|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.nava.informa.utils.toolkit.WorkersManager
public class WorkersManager
This class manages worker threads. Its main responsibility is to create / remove worker threads
and distribute tasks among them. This is an effort to hide complexity of threading logic from
the rest of toolkit. Worker manager receives processing requests from external tools and assigns
them to free worker threads. If there's no free worker thread left manager puts item in queue.
When worker thread finishes its job it asks for next job using JobSource
callback
interface. If there is at least one job in queue manager assigns it to worker. If not then
worker goes to rest until manager has something to assign.
Worker manager uses instance of WorkerThreadFactoryIF
specified on creation
to create new worker threads. Client application should use it to create and initialize
task-specific workers, which will be started as independent threads.
It's possible to tune number of threads working at a given time using
setWorkerThreads(int)
method call. Right after the number of threads will change
manager will stop unnecessary threads (only after running task completion) or create
new worker threads.
Constructor Summary | |
---|---|
WorkersManager(WorkerThreadFactoryIF factory)
Creates worker manager with default number of worker threads. |
|
WorkersManager(WorkerThreadFactoryIF factory,
int workerThreads)
Creates worker manager. |
Method Summary | |
---|---|
void |
process(ChannelRecord record)
Put the record in processing. |
void |
setWorkerThreads(int count)
Changes number of worker threads. |
void |
terminateAll()
Terminates all worker threads. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WorkersManager(WorkerThreadFactoryIF factory)
factory
- worker threads factory.public WorkersManager(WorkerThreadFactoryIF factory, int workerThreads)
factory
- worker threads factory.workerThreads
- number of worker threads.Method Detail |
---|
public final void setWorkerThreads(int count)
count
- new number of worker threads.public final void terminateAll()
public final void process(ChannelRecord record)
record
- record to process.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |