Class DistThreadPool
java.lang.Object
edu.jas.util.DistThreadPool
Distributed thread pool. Using stack / list work-pile and Executable Channels
and Servers.
- Author:
- Heinz Kredel
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intNumber of idle workers.protected LinkedList<Runnable> Work queue / stack.protected StrategyEnumerationprotected final intNumber of threads to use.protected edu.jas.util.DistPoolThread[]Array of workers. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new DistThreadPool with strategy StrategyEnumeration.FIFO and size DEFAULT_SIZE.DistThreadPool(int size) Constructs a new DistThreadPool with strategy StrategyEnumeration.FIFO.DistThreadPool(int size, String mfile) Constructs a new DistThreadPool with strategy StrategyEnumeration.FIFO.DistThreadPool(StrategyEnumeration strategy) Constructs a new DistThreadPool with size DEFAULT_SIZE.DistThreadPool(StrategyEnumeration strategy, int size, String mfile) Constructs a new DistThreadPool. -
Method Summary
Modifier and TypeMethodDescriptionvoidadds a job to the workpile.getEC()the used executable channel.protected RunnablegetJob()get a job for processing.intnumber of worker threads.get used strategy.booleanhasJobs()check if there are jobs for processing.booleanhasJobs(int n) check if there are more than n jobs for processing.voidinit()thread initialization and start.voidTerminates the threads.voidterminate(boolean shutDown) Terminates the threads.toString()String representation.
-
Field Details
-
threads
protected final int threadsNumber of threads to use. -
workers
protected edu.jas.util.DistPoolThread[] workersArray of workers. -
idleworkers
protected int idleworkersNumber of idle workers. -
jobstack
Work queue / stack. -
strategy
-
-
Constructor Details
-
DistThreadPool
public DistThreadPool()Constructs a new DistThreadPool with strategy StrategyEnumeration.FIFO and size DEFAULT_SIZE. -
DistThreadPool
Constructs a new DistThreadPool with size DEFAULT_SIZE.- Parameters:
strategy- for job processing.
-
DistThreadPool
public DistThreadPool(int size) Constructs a new DistThreadPool with strategy StrategyEnumeration.FIFO.- Parameters:
size- of the pool.
-
DistThreadPool
Constructs a new DistThreadPool with strategy StrategyEnumeration.FIFO.- Parameters:
size- of the pool.mfile- machine file.
-
DistThreadPool
Constructs a new DistThreadPool.- Parameters:
strategy- for job processing.size- of the pool.mfile- machine file.
-
-
Method Details
-
toString
-
init
public void init()thread initialization and start. -
getNumber
public int getNumber()number of worker threads. -
getStrategy
get used strategy. -
getEC
the used executable channel. -
terminate
public void terminate(boolean shutDown) Terminates the threads.- Parameters:
shutDown- true, if shut-down of the remote executable servers is requested, false, if remote executable servers stay alive.
-
terminate
public void terminate()Terminates the threads. -
addJob
-
getJob
get a job for processing.- Throws:
InterruptedException
-
hasJobs
public boolean hasJobs()check if there are jobs for processing. -
hasJobs
public boolean hasJobs(int n) check if there are more than n jobs for processing.- Parameters:
n- Integer- Returns:
- true, if there are possibly more than n jobs.
-