package learn.thread;
public class Demo8 extends Thread {
public volatile static boolean open = true;
public volatile static int num = 0;
public Demo8(String name) {
super(name);
}
String name;
@Override
public void run() {
while (open) {
System.out.println("循环");
}
System.out.println("while循环停止");
System.out.println("num: " + num);
}
public static void main(String[] args) {
Demo8 t1 = new Demo8("A");
t1.start();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
Demo8.open = false;
Demo8.num = 5;
}
}