Quit program that is running in command shell

J

Java and Swing

I have a Java app that is compiled into a JAR file. I then execute the
program from the command line (on windows xp) like this:

c:> java -jar MyApp.jar

.....works fine. Then at some point I want to quit the app by pressing
Ctrl + C....but it doesn't shut down. Now, the application has several
threads running....which have a "stopThread" method which I need to
call, but I need to know when to call them. i.e. how do I know the app
is trying to shutdown so that I can kill the threads?

thanks
 
J

Java and Swing

Thanks, I added a shutdownhook to the runtime, in there I stop all
threads and call Runtime.getRuntime().halt(1);

works great.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,272
Latest member
MaricruzDu

Latest Threads

Top