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() 测试
原创wx5a8fb619345a4 ©著作权
©著作权归作者所有:来自51CTO博客作者wx5a8fb619345a4的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Java线程池newSingleThreadExecutor newFixedThreadPool newCachedThreadPool newScheduledThreadPool
Java线程池newSingleThreadExecutor newFixedThreadPool newCachedThreadPool
Java线程池 newSingleThreadExecu newFixedThreadPool newCachedThreadPool newScheduledThreadPo