0
Having error with sleep method!!!
I have this "java.lang.illegalThreadStateException" error! when I use "Thread.sleep (1000);" does anybody have idea of how can I handle it?
4 Antworten
+ 3
import java.util.*;
public class Program
{
public static void main(String[] args) {
try {
Thread.currentThread().sleep(1000);
} catch (InterruptedException e){
e.printStackTrace();
}
}
}
0
why currentThread fix this problem?
0
Thread is a class so u cant say Thread.sleep();
correction is thread_name.sleep(duration);
if u wanna give sleep for current one then ammdy shafyu Is correct
0
It will create an interrupted exception