| 52 | }; |
| 53 | |
| 54 | int main() |
| 55 | { |
| 56 | // Create an instance of our threaded object. |
| 57 | my_object t; |
| 58 | |
| 59 | dlib::sleep(4000); |
| 60 | |
| 61 | // Tell the threaded object to pause its thread. This causes the |
| 62 | // thread to block on its next call to should_stop(). |
| 63 | t.pause(); |
| 64 | |
| 65 | dlib::sleep(3000); |
| 66 | cout << "starting thread back up from paused state" << endl; |
| 67 | |
| 68 | // Tell the thread to unpause itself. This causes should_stop() to unblock |
| 69 | // and to let the thread continue. |
| 70 | t.start(); |
| 71 | |
| 72 | dlib::sleep(4000); |
| 73 | |
| 74 | // Let the program end. When t is destructed it will gracefully terminate your |
| 75 | // thread because we have set the destructor up to do so. |
| 76 | } |
| 77 | |
| 78 | |
| 79 | |