/* * Copyright (C) 2004 Aleksandar Colovic * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * */ #include #include #include #include #include #include #include using namespace std; void* doWork(void* pArg) { for (int i = 0; i < 4; ++i) { cout << "Worker thread doing the job!" << endl; sleep(1); } return 0; } int main (int argc, char* const argv[]) { pthread_t hThread; pthread_create(&hThread, 0, &doWork, 0); sleep(2); cout << "Main thread sending SIGSTOP to worker thread!" << endl; pthread_kill(hThread, SIGSTOP); for (int i = 0; i < 2; ++i) { cout << "Main thread doing the job!" << endl; sleep(1); } cout << "Main thread sending SIGCONT to worker thread!" << endl; pthread_kill(hThread, SIGCONT); pthread_join(hThread, 0); return 0; };