top of page

Thread Pool & Shutdown Hook

  • Writer: Keshari Abeysinghe
    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 !

 
 
 

Recent Posts

See All
The Daemon Thread in Java

Daemon thread in Java provides service to the user thread which runs in the background. It is considered to be a low priority thread...

 
 
 

Comments


Subscribe Form

Thanks for submitting!

©2020 by Quick Code. Proudly created with Wix.com

bottom of page