package J20250730; /** * @author WanJl * @version 1.0 * @title Demo04_sleep * @description * @create 2025/7/30 */ public class Demo04_sleep { public static void main(String[] args) { Runnable run1=()->{ for (int i = 0; i < 1000; i++) { if (i==756) { try { Thread.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } } System.out.println(Thread.currentThread().getName()+"->"+i); } }; Thread t1=new Thread(run1,"线程1"); Thread t2=new Thread(run1,"线程2"); t1.start(); t2.start(); } }