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?

9th Aug 2016, 5:27 PM
Ali Ashkani nia
4 Respuestas
+ 3
import java.util.*; public class Program { public static void main(String[] args) { try { Thread.currentThread().sleep(1000); } catch (InterruptedException e){ e.printStackTrace(); } } }
9th Aug 2016, 5:38 PM
Ahmed Shafeeu
Ahmed Shafeeu - avatar
0
why currentThread fix this problem?
9th Aug 2016, 10:57 PM
WPimpong
WPimpong - avatar
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
16th Aug 2016, 2:25 AM
Rupesh L. Patil
Rupesh L. Patil - avatar
0
It will create an interrupted exception
13th Sep 2016, 2:47 PM
Rupali Gupta