62,614
社区成员
发帖
与我相关
我的任务
分享
public class Test {
private static boolean b;
private static int i = 1;
public static void main(String[] args) throws InterruptedException {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
while (!b) {
System.out.println(i);
}
}
});
thread.start();
TimeUnit.SECONDS.sleep(1);
b = true;
i = 2;
System.out.println(b);
}
}