|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectquestion2.ThreadPool
public class ThreadPool
Un pool de Thread,
Le pool consiste en la création anticipée de plusieurs
"Thread" ensuite affectés aux requêtes émises par l'utilisateur.
La méthode public void execute(Runnable r);
recherche un "Thread" disponible et exécute la méthode
public void run()
du paramètre r
Si aucun thread n'est disponible l'appelant est bloqué.
Les mesures en termes de performance restent à faire,
Les tests probants aussi
bibliographie utilisée :
http://developer.java.sun.com/developer/onlineTraining/Programming/JDCBook/perf.html
http://www.itec.uni-klu.ac.at/~harald/CSE/Content/index_CSE.html
http://developer.java.sun.com/developer/Books/threads/chap13.pdf
Constructor Summary | |
---|---|
ThreadPool(int max)
Création d'un "pool de thread", Chaque Thread est créé et est en attente d'une requête d'un client |
Method Summary | |
---|---|
void |
execute(java.lang.Runnable r)
Cette méthode sélectionne le prochain Thread libre, L'appelant est bloqué lorsque le pool est vide. |
boolean |
stopAll()
Arrete tous les Threads du pool. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ThreadPool(int max)
max
- le nombre de thread souhaitéMethod Detail |
---|
public void execute(java.lang.Runnable r)
ThreadPool pool = new ThreadPool(10);
pool.execute(r);
r
- le corps du Thread à exécuterpublic boolean stopAll()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |