foxtrot.workers
Class MultiWorkerThread

java.lang.Object
  extended by foxtrot.AbstractWorkerThread
      extended by foxtrot.workers.SingleWorkerThread
          extended by foxtrot.workers.MultiWorkerThread
All Implemented Interfaces:
WorkerThread, Runnable

public class MultiWorkerThread
extends SingleWorkerThread

Full implementation of WorkerThread that uses one or more threads to run Tasks subclasses.
Tasks execution is parallelized: two tasks posted at the same time are executed in parallel by two different threads. This is done by using a mechanism similar to a classic web server threading: one thread waits for incoming tasks and a new thread is spawned to run the task. This ensures that the SingleWorkerThread.postTask(foxtrot.Task) method returns immediately in any case.

Version:
$Revision: 263 $

Constructor Summary
MultiWorkerThread()
           
 
Method Summary
protected  String getThreadName()
          Returns the name of the worker thread used by this WorkerThread.
 boolean isWorkerThread()
          Returns whether the current thread is a thread used by the implementation of this WorkerThread to run Tasks.
protected  void run(Task task)
          Executes the given Task.
 
Methods inherited from class foxtrot.workers.SingleWorkerThread
isAlive, isThreadInterrupted, postTask, run, start, stop, takeTask
 
Methods inherited from class foxtrot.AbstractWorkerThread
runTask
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiWorkerThread

public MultiWorkerThread()
Method Detail

getThreadName

protected String getThreadName()
Description copied from class: SingleWorkerThread
Returns the name of the worker thread used by this WorkerThread.

Overrides:
getThreadName in class SingleWorkerThread

run

protected void run(Task task)
Description copied from class: SingleWorkerThread
Executes the given Task. This implementation will just call AbstractWorkerThread.runTask(foxtrot.Task).

Overrides:
run in class SingleWorkerThread

isWorkerThread

public boolean isWorkerThread()
Description copied from interface: WorkerThread
Returns whether the current thread is a thread used by the implementation of this WorkerThread to run Tasks.

Specified by:
isWorkerThread in interface WorkerThread
Overrides:
isWorkerThread in class SingleWorkerThread


Copyright © 2011 KnowledgePlaza. All Rights Reserved.