KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > snow > concurrent > Interrupter


1 package snow.concurrent;
2
3 /** this is part of an interrupatble task.
4     It signal a task that it should stop the evaluation.
5     It is a safe and lazy method to stop a thread, but the thread must
6     programmatically often check if it must stop !
7 */

8 public class Interrupter
9 {
10   private boolean shouldStop = false;
11
12   public void stopEvaluation() { shouldStop = true; }
13   public boolean shouldStopEvaluation() { return shouldStop; }
14
15   public Process JavaDoc process = null;
16
17   public void setProcessToOptionalKill(Process JavaDoc p){
18     this.process = p;
19   }
20
21   /** use this to reset the interrupter.
22   */

23   public void reset()
24   {
25      shouldStop = false;
26   }
27
28 } // Interrupter
Popular Tags