Kalana Sarange
Kalana Sarange

Reputation: 77

How to Close a swing application properly

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

Answers (2)

user2511414
user2511414

Reputation:

use System.exit(0); causes JVM kills the application silently, OR make other threads as daemon

Upvotes: 3

Maroun
Maroun

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

Related Questions