public class Qiao3 { public static void main(String[] args) { Thread thread1 = new Thread(()->{ System.out.println("111"); try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("222"); }); Thread thread2 = new Thread(()->{ System.out.println("333"); try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("444"); }); Thread thread3 = new Thread(()->{ System.out.println("555"); try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("666"); }); ExecutorService executorService = Executors.newSingleThreadExecutor(); executorService.execute(thread1); executorService.submit(thread2); executorService.execute(thread3); System.out.println("ok"); } }
Executors.newSingleThreadExecutor() 测试
最新推荐文章于 2025-07-05 07:30:00 发布