VOOZH about

URL: https://www.geeksforgeeks.org/java/how-to-temporarily-stop-a-thread-in-java/

⇱ Temporarily Stop a Thread in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Temporarily Stop a Thread in Java

Last Updated : 24 Apr, 2026

In Java, sometimes a thread needs to pause its execution for a specific period of time before continuing its work. This can be done using the Thread.sleep() method, which temporarily suspends the current thread.

  • The time is provided in milliseconds.
  • It throws an InterruptedException, so it must be handled using try-catch.

Note: suspend() method is deprecated in the latest Java version.

Syntax:

public final void suspend()

Output

👁 Thread 2 is suspended

Explanation: Three threads (t1, t2, t3) are created and started, so they run concurrently and execute the run() method independently. Each thread prints its name and numbers 1–4 with a small delay, so the output appears interleaved and in random order due to multithreading.

Note: Thread t2 can be resumed by resume() method.

Comment