Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Threads suspend/resume

Tags:

People also ask

How do I suspend a resume thread in Linux?

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.

What is used to resume the suspended thread?

resume(): This is a method used to resume the suspended thread.

What is the difference between suspend () and resume () methods?

In this case, the suspend() method allows a thread to temporarily cease executing. resume() method allows the suspended thread to start again.

How do I temporarily stop a thread?

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.