In my Swing application, as soon as I start the main() method, a dialog containing Username and Password fields with OK and Cancel buttons gets popped-up. I have a propertyChangeListener which gets notified when Ok or cancel is pressed and when Cancel is pressed, System.exit(0) is called to exit the JVM.
So, there are two threads running - One - the main thread which invokes the dialog pop-up Second - the propertychangelistener which calls the System.exit(0) on pressing Cancel button.
So, at times, after pressing cancel button, the application does not exit but invokes the previously running thread (main thread). But this does not happen always.
Could you please let me know why the application does not terminate completely and how to resolve this?