Always shut down an ExecutorService
The ExecutorService interface is among the most commonly used items in the java.util.concurrent package. When finished using an ExecutorService, you need to shut it down explicitly. From its javadoc:
"An unused ExecutorService should be shut down to allow reclamation of its resources."
Calling shutdown initiates a gradual and orderly shutdown. Submitted tasks are still executed, but no new tasks will be accepted. If you then want to wait until shutdown has completed, call awaitTermination.
Alternatively, call
shutdownNow
to terminate in a more aggressive manner.
Would you use this technique?
|
|