22 lines
609 B
Java
22 lines
609 B
Java
package thead.thread_4;
|
|
|
|
public class Application {
|
|
// 有线程安全的操作
|
|
public static void main(String[] args) throws InterruptedException {
|
|
MyThread t1 = new MyThread("t1");
|
|
MyThread t2 = new MyThread("t2");
|
|
MyThread t3 = new MyThread("t3");
|
|
System.out.println("是否中断:" + t1.isInterrupted());
|
|
|
|
t1.start();
|
|
t2.start();
|
|
t3.start();
|
|
|
|
Thread.sleep(100);
|
|
System.out.println("是否中断:" + t1.isInterrupted());
|
|
|
|
t1.interrupt();
|
|
System.out.println("是否中断:" + t1.isInterrupted());
|
|
}
|
|
}
|