Leaked concurrency handle (ARCH4085)
هذا المحتوى غير متوفر بلغتك بعد.
Key java.performance.leaked-concurrency-handle · Severity warning · Category performance
A pool created with Executors.newFixedThreadPool and never shutdown() keeps non-daemon threads alive and prevents the JVM from exiting.
Incorrect
Section titled “Incorrect”public void run(List<Task> tasks) { ExecutorService pool = Executors.newFixedThreadPool(4); tasks.forEach(pool::submit);}Correct
Section titled “Correct”public void run(List<Task> tasks) { ExecutorService pool = Executors.newFixedThreadPool(4); try { tasks.forEach(pool::submit); } finally { pool.shutdown(); }}Shut down created executor pools with shutdown() in a finally block or try-with-resources.