Using an Executor Service 2 – Concurrency: Part II

When the executor service is no longer needed, it should be closed properly so that resources associated with the executor service can be reclaimed. As an executor service is not AutoCloseable, we cannot use the try-with-resources statement. The simplest shutdown procedure involves either calling the shutdown() or shutdownNow() method for this purpose. Calling either of

Using an Executor Service – Concurrency: Part II

Using an Executor Service The idiom for using an executor service is embodied in the following steps that are illustrated in Example 23.1: • Create the executor service. • Submit tasks to the executor service. • Shut down and terminate the executor service. Example 23.1 Executor Lifecycle Click here to view code image package executors;import
BACK TO TOP