public class SleepDemo {
public static void main(String[] args) throws InterruptedException {
Process process = new Process();
Thread thread = new Thread(process);
thread.setName("线程Process");
thread.start();
for (int i = 0; i < 10; i++) {
System.out.println(Thread.currentThread().getName() + "-->" + i);
//阻塞main线程,休眠一秒钟
Thread.sleep(1000);
}
}
}
QQ图片20220227133448.jpg