ThreadPoolExecutor回收不了,可以看看其源码,工作线程Worker是内部类,只要它活着,换句话说线程在跑,就会阻止ThreadPoolExecutor回收,所以其实ThreadPoolExecutor是无法回收的,并不能认为ThreadPoolExecutor没有引用就能回收
我觉得不会被回收且很快就会OOM了,因为每次请求都新建线程池,每个线程池的核心数都是10, 虽然自定义线程池设置2秒回收,但是没超过线程池核心数10是不会被回收的, 不间断的请求过来导致创建大量线程,最终OOM。 Exception in thread “main” java.lang.OutOfMemoryError: unable to create new native thread