Ticket #4524: sem.cc
| File sem.cc, 289 bytes (added by , 12 years ago) |
|---|
| Line | |
|---|---|
| 1 | #include <boost/interprocess/sync/interprocess_semaphore.hpp> |
| 2 | #include <boost/thread/thread.hpp> |
| 3 | #include <unistd.h> |
| 4 | |
| 5 | boost::interprocess::interprocess_semaphore sem(0); |
| 6 | |
| 7 | void thr1() |
| 8 | { |
| 9 | sem.wait(); |
| 10 | } |
| 11 | |
| 12 | int main() |
| 13 | { |
| 14 | boost::thread t1(thr1); |
| 15 | sleep(10); |
| 16 | sem.post(); |
| 17 | t1.join(); |
| 18 | return 0; |
| 19 | } |
