Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

wait(); try catch code is not works in java

I tried to make a wait code in java but its not worked. What can i do?
`

//i used if code
}else try {
            creatingr.setValue(4);
            wait(4);
            creatingr.setValue(12);
        } catch (Exception e) {
            Logger.getLogger(Rep_App.class.getName()).log(Level.SEVERE, null, e);
        }

`

JProgressBar value is not worked.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The wait() method doesn’t work that way. The wait() method causes the current thread to wait indefinitely until another thread either invokes notify() for this object or notifyAll(). You will want to use Thread.sleep(Long milliseconds) instead.

try {
    creatingr.setValue(4);
    Thread.sleep(4000);
    creatingr.setValue(12);
} catch (Exception e) {
    Logger.getLogger(Rep_App.class.getName()).log(Level.SEVERE, null, e);
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading