Reputation: 77
I make a java swing application with some threads. When I pressed 'x' button in window, all running threads stopped and application close properly. But I want to close the application from java code. I used this.dispose(); for close the application. But when I used that method, window is closed. But all threads are still running. How I closed the application properly. please help me.
Upvotes: 2
Views: 2894
Reputation:
use System.exit(0);
causes JVM kills the application silently, OR make other threads as daemon
Upvotes: 3
Reputation: 95968
See public static void exit(int status)
Terminates the currently running Java Virtual Machine.
But be careful when you use this in multi-threaded application.
Upvotes: 1