package com.pra;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* @author evi
* @version 1.0.0
* @date 2019\8\15 22:00
*/
public class MewThread {
static Thread thread1=new Thread(new Runnable() {
@Override
public void run() {
System.out.println("thread1 执行");
}
});
static Thread thread2=new Thread(new Runnable() {
@Override
public void run() {
System.out.println("thread2 执行");
}
});
static Thread thread3=new Thread(new Runnable() {
@Override
public void run() {
System.out.println("thread3 执行");
}
});
static ExecutorService executorService=Executors.newSingleThreadExecutor();
public static void main(String[] args) throws InterruptedException {
// //join:让主线程等待子线程结束以后才能继续运行
// System.out.println("Hello World");
// thread1.start();
// thread1.join();
// thread2.start();
// thread1.join();
// thread3.start();
executorService.submit(thread1);
executorService.submit(thread2);
executorService.submit(thread3);
executorService.shutdown();
}
}
线程顺序执行
猜你喜欢
转载自blog.csdn.net/qq_43669912/article/details/99660007
今日推荐
周排行