/**
* 创建线程池
*/
public class test03ThreadExecutor {
public static void main(String[] args) {
// TODO Auto-generated method stub
ExecutorService executorService = Executors.newFixedThreadPool(); //创建线程池,中有三个线程对象
MyRunnable1 myRunnable = new MyRunnable1();
executorService.submit(myRunnable);
executorService.submit(myRunnable);
executorService.submit(myRunnable);
executorService.shutdown();
}
}
class MyRunnable1 implements Runnable{
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("我要一个教练");
try {
Thread.sleep();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("教练来了"+Thread.currentThread().getName());
System.out.println("教练走了");
}
}