ExecutorService executor = Executors.newCachedThreadPool();
executor.submit(xxxxxx);
executor.shutdown();
在使用java自带线程池,并且每次使用都平滑关闭,但是线程池的序号还在不断的增加是为什么?
pool-1-thread-1
pool-1-thread-2
pool-1-thread-3
pool-2-thread-1
pool-2-thread-2
pool-2-thread-3
.........
不会重复利用序号pool-number吗?
一般使用线程池都是单例的。
你的代码里已经出现了两个线程池的实例了。所以出现了
pool-2
。