How to Temporarily Stop a Thread in Java? Last Updated : 24 Nov, 2020 Comments Improve Suggest changes 3 Likes Like Report 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. Syntax public final void suspend() Return: Does not return any value. Exception: Throws SecurityException If the current thread cannot modify the thread. Example: Java // Java program to demonstrate suspend() method // of Thread class import java.io.*; class GFG extends Thread { public void run() { for (int i = 1; i < 5; i++) { try { // thread to sleep for 500 milliseconds sleep(5); System.out.println( "Currently running - " + Thread.currentThread().getName()); } catch (InterruptedException e) { System.out.println(e); } System.out.println(i); } } public static void main(String args[]) { // creating three threads GFG t1 = new GFG(); GFG t2 = new GFG(); GFG t3 = new GFG(); // call run() method t1.start(); t2.start(); // suspend t2 thread t2.suspend(); // call run() method t3.start(); } } Output Note: Thread t2 can be resumed by resume() method. t2.resume() Create Quiz Comment G gunjanpaul Follow 3 Improve G gunjanpaul Follow 3 Improve Article Tags : Java Technical Scripter Java Programs Technical Scripter 2020 Java-Multithreading +1 More Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings7 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java5 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages2 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java4 min readJava Comparator Interface5 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java7 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management3 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like