Created a ThreadPoolExecutor without shutting it down after used will cause thread leak.
Noncompliant Code
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) Executors.newFixedThreadPool(1);
threadpool.submit(() -> {
...
});
Compilant Code
ThreadPoolExecutor threadpool = (ThreadPoolExecutor) Executors.newFixedThreadPool(1);
try {
threadpool.submit(() -> {
...
});
} finally {
threadpool.shutdown();
}
Type : Bug