In this code example, the ExecutorService is used one and allowed to go out of scope.
public static void main(String[] args)
{
ExecutorService executorSe
If you want the threads to be finalized when the Executor service is out of scope you should avoid, as mjt suggested, the use of
ExecutorService executorService = Executors.newFixedThreadPool(3);`
and use for example:
ExecutorService executorService = new ThreadPoolExecutor(0, 3, 10, TimeUnit.MILLISECONDS, new LinkedBlockingQueue());