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.
>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);
}