Could not find this answer online. When Ctrl+C is hit:
Thanks!
Each JVM server can have a maximum of 256 threads to run Java applications. In a CICS region you can have a maximum of 1024 threads. If you have many JVM servers running in the CICS region, you cannot set the maximum value for every JVM server.
To coordinate shared data access among multiple threads, the Java virtual machine associates a lock with each object and class. A lock is like a privilege that only one thread can "possess" at any one time. If a thread wants to lock a particular object or class, it asks the JVM.
Shutdown hooks are called when the application terminates normally (when all threads finish, or when System. exit(0) is called).
Multi-thread programming allows us to run threads concurrently, and each thread can handle different tasks.
The classic book "Java Concurrency in Practice" has a chapter (7.4) on the JVM shutdown, you should read that, but here are some relevant quotes:
If any application threads (daemon or nondaemon) are still running at shutdown time, they continue to run concurrently with the shutdown process.
The JVM makes no attempt to stop or interrupt any application threads that are still running at shutdown time; they are abruptly terminated when the JVM eventually halts.
So the threads are not interrupted, but you can interrupt them explicitly from the shutdown hook, if you wish.
IMO, Daemon threads will continue to run during shutdown process and JVM will kill all running threads later when its time to exit the application. I don't think, running threads will get InterruptedException
as JVM doesn't make any extra effort to stop running threads.
http://www.tutorialspoint.com/java/lang/runtime_addshutdownhook.htm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With