How to suspend current thread for X seconds in java?

+1 vote
110 views
asked Nov 17, 2017 by Hitesh Garg (343 points)  

How to suspend a current Thread for X seconds lets say 10 seconds in Java?

1 Answer

+1 vote
answered May 24 by Hitesh Garg (343 points)  
 
Best answer

It can be easily done by the Thread.sleep method.

So the code below will put a thread to sleep for 50 seconds

try {
  Thread.sleep(50*1000);
} catch(InterruptedException e) { 
}
Welcome to Codingeek Q&A, where you can ask questions and receive answers from other members of the community.
...