//创建单一线程
ExecutorService executorService= Executors.newSingleThreadExecutor();
//创建可伸缩线程
ExecutorService executorService1=Executors.newCachedThreadPool();
//指定创建3个线程
ExecutorService executorService2=Executors.newFixedThreadPool(3);

一般不会用newCachedThreadPool太耗费内存,而newSingleThreadExecutor和newFixedThreadPool

容易积累大量的oom异常

用工具类创建线程池_hh