public class ThreadPool
extends java.lang.Object
implements java.io.Serializable
Once the ThreadPool object myPool is created, any task myTask implementing the Runnable interface can be submitted to the pool by using the following command:
myPool.run(myTask);
Constructor and Description |
---|
ThreadPool()
Use this constructor to create a ThreadPool object without
setting the servers.
|
ThreadPool(java.lang.String[] servers)
Use this constructor to create a ThreadPool object with a
predefined number of servers.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String server)
add a new server to the ThreadPool object.
|
int |
getNumberOfJobs()
return the number of jobs in the pool.
|
void |
join()
wait until all jobs have been executed.
|
void |
join(int iset)
wait until iset jobs are remaining in the pool.
|
void |
run(java.lang.Runnable task)
add a new job to the pool.
|
public ThreadPool(java.lang.String[] servers)
servers
- IP identification of the servers.public ThreadPool()
public int getNumberOfJobs()
public void add(java.lang.String server)
server
- IP identification of the new server.public void run(java.lang.Runnable task)
task
- job implementing the Runnable interface.public void join()
public void join(int iset)