Class DistThreadPool
java.lang.Object
edu.jas.util.DistThreadPool
Distributed thread pool. Using stack / list work-pile and Executable Channels
and Servers.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final booleanprivate static final Stringdefault machine file for test.(package private) static final intDefault number of threads to use.(package private) final ExecutableChannelsChannels to remote executable servers.protected intNumber of idle workers.protected LinkedList<Runnable> Work queue / stack.private static final org.apache.logging.log4j.Loggerprivate final Stringmachine file to use.protected StrategyEnumerationprotected final intNumber of threads to use.protected 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
-
mfile
machine file to use. -
DEFAULT_MFILE
-
threads
protected final int threadsNumber of threads to use. -
DEFAULT_SIZE
static final int DEFAULT_SIZEDefault number of threads to use.- See Also:
-
ec
Channels to remote executable servers. -
workers
Array of workers. -
idleworkers
protected int idleworkersNumber of idle workers. -
jobstack
Work queue / stack. -
strategy
-
logger
private static final org.apache.logging.log4j.Logger logger -
debug
private static final boolean debug- See Also:
-
-
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.
-