Java wait for JFrame to finish -


I have a login frame for which I have to wait from the second thread. Removes itself on successful login frames and I want to pop the main frame for the application. Right now I am looking at the boolean value while firing the main frame. What is the right way to do this? Viewing a Boolean value just does not look elegant.

If you have Java 5 or later available, you use. For example, suppose the main frame is initially in control, make CountDownLatch in the main frame with counting 1 and pass this latch to the login frame. Then the main frame for the match should be waiting for 0:

  countdownload loginsign = new countdownload (1); ... // Start the login frames, login it Signal ... // execute the login frame in another thread / this wait () blocks until we are logged in: loginSignal.await ( );  

Log frame, when done, reduce the lat:

  loginSignal.countDown ();  

Make sure there is no way out of your login frame, from where it forgets to reduce the waste! As soon as reaching CountDownLatch 0, the main frame becomes runable.

You can also (or use any of the other options from java.util) concurrently ), but for this purpose, a countdown to < / Code> seems easy to use.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -