Open In App
Related Articles

How to Temporarily Stop a Thread in Java?

Improve Article
Save Article
Like Article

The suspend() method of thread class puts the thread from running to waiting state. This method is employed if you would like to prevent the thread execution and begin it again when a particular event occurs. This method allows a thread to temporarily cease execution. The suspended thread is often resumed using the resume() method. If the present thread cannot modify the target thread then it’ll throw Security Exception.

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


public final void suspend()

Return: Does not return any value.

Exception: Throws SecurityException If the current thread cannot modify the thread.



// Java program to demonstrate suspend() method
// of Thread class
class GFG extends Thread {
    public void run()
        for (int i = 1; i < 5; i++) {
            try {
                // thread to sleep for 500 milliseconds
                    "Currently running - "
                    + Thread.currentThread().getName());
            catch (InterruptedException e) {
    public static void main(String args[])
        // creating three threads
        GFG t1 = new GFG();
        GFG t2 = new GFG();
        GFG t3 = new GFG();
        // call run() method
        // suspend t2 thread
        // call run() method


Thread 2 is suspended

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


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 24 Nov, 2020
Like Article
Save Article
Similar Reads
Complete Tutorials