-1

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?

user3607022
  • 480
  • 3
  • 16

2 Answers2

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

Community
  • 1
  • 1
PM 77-1
  • 12,933
  • 21
  • 68
  • 111
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