1 7 8 package java.util.concurrent.locks; 9 import java.util.concurrent.*; 10 import sun.misc.Unsafe; 11 12 13 76 77 public class LockSupport { 78 private LockSupport() {} 80 private static final Unsafe unsafe = Unsafe.getUnsafe(); 82 83 93 public static void unpark(Thread thread) { 94 if (thread != null) 95 unsafe.unpark(thread); 96 } 97 98 117 public static void park() { 118 unsafe.park(false, 0L); 119 } 120 121 144 public static void parkNanos(long nanos) { 145 if (nanos > 0) 146 unsafe.park(false, nanos); 147 } 148 149 173 public static void parkUntil(long deadline) { 174 unsafe.park(true, deadline); 175 } 176 177 } 178 179 180 | Popular Tags |