Signal SIGUSR1 suspends the thread by calling pause() and SIGUSR2 resumes the thread. From the man page of pause: This example is problematic for numerous reasons. It is not thread safe: you do not wait until thread1 and thread2 set their signal handlers before calling pthread_kill.
resume(): This is a method used to resume the suspended thread.
In this case, the suspend() method allows a thread to temporarily cease executing. resume() method allows the suspended thread to start again.
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.
I'm writing a code in which I have two threads running in parallel.
1st is the main thread which started the 2nd thread. 2nd thread is just a simple thread executing empty while loop.
Now I want to pause / suspend the execution of 2nd thread by 1st thread who created it. And after some time I want to resume the execution of 2nd thread (by issuing some command or function) from where it was paused / suspended.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With