public class ThreadAndAllBreakApplication {
public static void main(String[] args) {
ThreadTest thread1 = new ThreadTest();
thread1.setName("线程A");
thread1.start();
ThreadTest thread2 = new ThreadTest();
thread2.setName("线程B");
thread2.start();
ThreadTest thread3 = new ThreadTest();
thread3.setName("线程C");
thread3.start();
}
}
class ThreadTest extends Thread {
@Override
public void run() {
System.out.println(Thread.currentThread().getName() + ": 1");
try {
long millis = RandomUtil.randomLong(100, 500);
System.out.println(Thread.currentThread().getName() + "睡眠: " + millis);
Thread.sleep(millis);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(Thread.currentThread().getName() + ": 2");
System.out.println(Thread.currentThread().getName() + ": 3");
System.out.println(Thread.currentThread().getName() + ": 设置断点的前一行代码"); // 当前行设置断点
System.out.println(Thread.currentThread().getName() + ": 4");
System.out.println(Thread.currentThread().getName() + ": end");
|