Which method can be used to temporarily pause the execution of a thread for a specified time?

  • pause()
  • sleep()
  • stop()
  • yield()
The sleep() method in Java is used to temporarily pause the execution of a thread for a specified amount of time. It's a way to introduce delays in a program and is often used for synchronization or timing purposes. The other options are not used for pausing threads in this manner.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *