Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make proper use of java.lang.Terminator?

  • What does this class exactly do?

  • What is a "termination-triggered shutdowns"?

  • Where have you used this in your program or what could be a good use case for this class?

like image 616
unj2 Avatar asked Oct 21 '25 11:10

unj2


2 Answers

Taking your points one at a time:

  • What does this class do? It handles termination signals received from the Operating System.

  • What are "termination-triggered shutdowns"? A shut down of the JVM caused by the Operating System sending a signal to the Java process, e.g. when you shut down your computer.

  • How can it be used? It's not intended for use in your programs as it is package private and is used by the JVM itself to handle termination signals received from the Operating System.

like image 146
BenM Avatar answered Oct 24 '25 01:10

BenM


It's package private - so you're not supposed to use it. Better look at Design of the Shutdown Hooks API if you want to execute code upon shutdown.

like image 20
Anton Avatar answered Oct 24 '25 00:10

Anton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!