public static void main(String[] args) {
ExecutorService service= Executors.newFixedThreadPool(1);
System.out.println(System.currentTimeMillis());
for (int i = 0; i < 10; i++) {
Runnable runnable=new Runnable() {
@Override
public void run() {
long time=3000;
try {
Thread.sleep(time);
System.out.println(Thread.currentThread().getName()+"休眠了 "+time+" ms");
} catch (Exception e) {
e.printStackTrace();
}
}
};
service.execute(runnable);
}
service.shutdown();
System.out.println(System.currentTimeMillis());
System.out.println("Now,main is just over");
}
直接over了,没有阻塞啊,怎么回事?