Typically what you would want to do is check a variable/condition within your new thread and act accordingly.
thread_executor(...)
{
while(run){
if(pause) continue;
else{
}
}
}
There are some thread implementations that allow for external suspension of a thread but its not a recommended or ideal practice because it leaves the thread memory and accessors in an undefined state (i.e. what happens to the variables that you're using within that thread? what if you locked a shared memory location with a mutex?).
edit: There are some thread implementations (can't recall which one off the top of my head) that would lead a "tight" loop into taking up a lot of processor time (i.e. the continue statement above). In those cases, you can also save some cycles by sleeping for some period of time (i.e.
if(pause) sleep(10)
). Alternatively, you can use a control signal (in Windows, look up
WaitForSingleObject()
), but be sure to use timeouts so you don't lock up threads.