它们是LockSupport类中的方法
// 暂停当前线程 LockSupport.park(); // 恢复某个线程的运行 LockSupport.unpark(Thread thread);
unpark即可以在park之后调用也可以在park之前调用,unpark的调用跟顺序无关。
@Slf4j public class ParkTest { public static void main(String[] args) throws InterruptedException { Thread t1 = new Thread(() -> { log.info("t1 start"); try { TimeUnit.SECONDS.sleep(3); log.info("t1 park"); LockSupport.park(); log.info("t1 resume ... "); } catch (InterruptedException e) { e.printStackTrace(); } }, "t1"); t1.start(); TimeUnit.SECONDS.sleep(10); log.info("main thread resume t1"); LockSupport.unpark(t1); } }