1 3 package jodd.util; 4 5 8 9 public class ThreadUtil { 10 11 16 public static void sleep(long ms) { 17 try { 18 Thread.sleep(ms); 19 } catch (InterruptedException iex) { 20 } 22 } 23 24 25 28 public static void sleep() { 29 try { 30 Thread.sleep(Long.MAX_VALUE); 31 } catch (InterruptedException iex) { 32 } 34 } 35 36 37 39 42 public static void wait(Object obj) { 43 synchronized (obj) { 44 try { 45 obj.wait(); 46 } catch (InterruptedException inex) { 47 } 49 } 50 } 51 52 55 public static void wait(Object obj, long timeout) { 56 synchronized (obj) { 57 try { 58 obj.wait(timeout); 59 } catch (InterruptedException inex) { 60 } 62 } 63 } 64 65 68 public static void notify(Object obj){ 69 synchronized (obj) { 70 obj.notify(); 71 } 72 } 73 74 77 public static void notifyAll(Object obj){ 78 synchronized (obj) { 79 obj.notifyAll(); 80 } 81 } 82 83 } | Popular Tags |