1 18 19 package org.apache.batik.util; 20 21 29 public class HaltingThread extends Thread { 30 33 protected boolean beenHalted = false; 34 35 public HaltingThread() { } 36 37 public HaltingThread(Runnable r) { super(r); } 38 39 public HaltingThread(String name) { super(name); } 40 41 public HaltingThread(Runnable r, String name) { super(r, name); } 42 43 46 public boolean isHalted() { 47 synchronized (this) { return beenHalted; } 48 } 49 50 53 public void halt() { 54 synchronized (this) { beenHalted = true; } 55 } 56 57 60 public void clearHalted() { 61 synchronized (this) { beenHalted = false; } 62 } 63 64 68 public static void haltThread() { 69 haltThread(Thread.currentThread()); 70 } 71 72 76 public static void haltThread(Thread t) { 77 if (t instanceof HaltingThread) 78 ((HaltingThread)t).halt(); 79 } 80 81 86 public static boolean hasBeenHalted() { 87 return hasBeenHalted(Thread.currentThread()); 88 } 89 90 94 public static boolean hasBeenHalted(Thread t) { 95 if (t instanceof HaltingThread) 96 return ((HaltingThread)t).isHalted(); 97 return false; 98 } 99 100 101 }; 102 | Popular Tags |