1.本身在使用的過程當中發現ExecutorService的submit方法會吞併異常。所以,作一下筆記。java
2.使用方式ide
ExecutorService executors = Executors.newFixedThreadPool(1); AtomicInteger atomicInteger = null; executors.submit(new Runnable() { @Override public void run() { System.out.println(atomicInteger.getAndIncrement());//在此並不會拋出異常 } }); executors.execute(new Runnable() { @Override public void run() { System.out.println(atomicInteger.getAndIncrement());//在此會拋出異常 } });