There is little valid reason to use the methods of the ThreadGroup
class. Some are deprecated (allowThreadSuspension()
,
resume()
, stop()
, and suspend()
), some are obsolete, others aren't thread-safe, and still others are insecure
(activeCount()
, enumerate()
) . For these reasons, any use of ThreadGroup
is suspicious and should be
avoided.
ThreadFactory threadFactory = Executors.defaultThreadFactory(); ThreadPoolExecutor executorPool = new ThreadPoolExecutor(3, 10, 5, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(2), threadFactory); for (int i = 0; i < 10; i++) { executorPool.execute(new JobThread("Job: " + i)); } System.out.println(executorPool.getActiveCount()); // Compliant executorPool.shutdown();