1 package zirc.threads ; 2 3 import java.util.* ; 4 5 18 25 26 public class ThreadProcessor extends Thread 27 { 28 private boolean isRunning; 30 31 private boolean arret ; 33 34 private LinkedList threadArray = new LinkedList() ; 36 37 public ThreadProcessor() 38 { 39 } 40 41 48 public void run() 49 { 50 isRunning = true; 52 53 PseudoThread tache; 55 56 while (!arret && (threadArray.size() > 0 ) ) 57 { 58 tache = (PseudoThread)(threadArray.get(0)); 59 60 if(tache != null) 62 { 63 tache.go(); 64 } 65 66 threadArray.remove(tache); 68 } 69 70 isRunning = false; 71 } 72 73 78 public void addThread(PseudoThread _thread) 79 { 80 threadArray.add(_thread) ; 82 83 if(isRunning == false) 85 { 86 run(); 87 } 88 } 89 90 96 public void arrete() 97 { 98 arret = true; 99 } 100 101 } 102 | Popular Tags |