How to suspend current thread for X seconds in java?

+1 vote
asked Nov 16, 2017 by Hitesh Garg (355 points)  

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

1 Answer

+1 vote
answered May 23, 2018 by Hitesh Garg (355 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 {
} catch(InterruptedException e) { 
Welcome to Codingeek Q&A, where you can ask questions and receive answers from other members of the community.