org.objectweb.proactive.core.group.threadpool
Class ThreadPool

java.lang.Object
  |
  +--org.objectweb.proactive.core.group.threadpool.ThreadPool

public class ThreadPool
extends java.lang.Object

A thread pool is a set of threads waiting for jobs. The thread in the pool are created one time and re-used for new jobs.


Field Summary
protected  EndControler controler
          The controler that is looking for the end of jobs to perform.
 
Constructor Summary
ThreadPool()
          Builds a ThreadPool.
ThreadPool(int size)
          Builds a ThreadPool, specifying the number of thread to create.
 
Method Summary
 void addAJob(AbstractProcessForGroup r)
          Adds a job to the pending queue of the thread pool.
 void checkNumberOfThreads(int members)
          Check wether the number of threads in this threadpool is sufficient compared to the number of members in the group
 void complete()
          Waits until the ThreadPool has no more job to execute (pending queue is empty).
protected  void createThreads(int number)
          Creates the needed threads for this ThreadPool
 void finalize()
          Cleanly destroys a ThreadPool object
 java.lang.Runnable getJobForThePendingQueue()
          Picks up new job to execute in the pending queue.
 void ratio(int i)
          Modifies the number of members served by one thread
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

controler

protected EndControler controler
The controler that is looking for the end of jobs to perform.

Constructor Detail

ThreadPool

public ThreadPool()
Builds a ThreadPool. By default, the number of thread in the pool is 10.


ThreadPool

public ThreadPool(int size)
Builds a ThreadPool, specifying the number of thread to create.

Method Detail

createThreads

protected void createThreads(int number)
Creates the needed threads for this ThreadPool


checkNumberOfThreads

public void checkNumberOfThreads(int members)
Check wether the number of threads in this threadpool is sufficient compared to the number of members in the group


ratio

public void ratio(int i)
Modifies the number of members served by one thread

Parameters:
i - - the new ratio

addAJob

public void addAJob(AbstractProcessForGroup r)
Adds a job to the pending queue of the thread pool.


getJobForThePendingQueue

public java.lang.Runnable getJobForThePendingQueue()
Picks up new job to execute in the pending queue.

Returns:
A new job to execute

complete

public void complete()
Waits until the ThreadPool has no more job to execute (pending queue is empty).


finalize

public void finalize()
Cleanly destroys a ThreadPool object

Overrides:
finalize in class java.lang.Object


Copyright © April 2004 INRIA All Rights Reserved.