Thread Pool & Shutdown Hook
- Keshari Abeysinghe

- Dec 7, 2020
- 1 min read
Updated: Dec 9, 2020
What is Thread Pool in Java?
A thread pool reuses previously created threads to execute current tasks and offers a solution to the problem of thread cycle overhead and resource thrashing. Since the thread is already existing when the request arrives, the delay introduced by thread creation is eliminated, making the application more responsive.
It is used in Servlet and JSP where container creates a thread pool to process the request.
Shutdown hook in Java
Java uses shut down hook for cleaning tasks such as performing clean resource means closing log file, sending some alerts or something else.Else that shutdownhook save the state when JVM shuts down normally or abruptly.The JVM shuts down when:
user presses ctrl+c on the command prompt
System.exit(int) method is invoked
user logoff
user shutdown etc.
Happy Coding !


Comments