栏目:一针见血 作者:admin 日期:2018-10-29 评论:0 点击: 727 次
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
public class Test { private static volatile int condition = 0; public static void main(String[] args) throws InterruptedException { Thread worker = new Thread(new Runnable() { public void run() { while (!(condition == 1)) { // 条件不满足,自旋 } System.out.println("a executed"); } }); worker.start(); Thread.sleep(2000); condition = 1; } } |
------====== 本站公告 ======------
金丝燕网,一个严谨的网站!