I am writing a multithreaded Java program, which I will run from the command prompt. It's got both a gui (javafx) and a lot of background threads. If I hit Ctrl+C from the command prompt that I started the program with, it asks "Terminate Batch job? Y/N" and I hit Y and then I'm simply returned to the prompt. However - I am wondering if there by any chance might still be running any background threads that weren't terminated gracefully?
Asked
Active
Viewed 139 times
-1
-
1have a reference to them in an array – Developerium Feb 15 '15 at 08:22
2 Answers
4
Your "main" code and all the threads run in JVM
. If you terminate JVM (as process) then everything running in it will be terminated as well.
More on "catching" ctrl+c
: Catching Ctrl+C in Java
1
As far as I know, there's no way to "catch" or "intercept" Ctrl+C "event" from the command line, so your can't really tell if there are any unfinished threads and end them gracefully. (disappointing, I know).

Ofer Lando
- 814
- 7
- 12