libphobos/testsuite/libphobos.init_fini/thread_join.d
raw| 1 | // Bugzilla 11309 - std.concurrency: OwnerTerminated message doesn't work |
| 2 | // We need to assure that the thread dtors of parent threads run before the thread dtors of the child threads. |
| 3 | import core.thread, core.sync.semaphore; |
| 4 | |
| 5 | __gshared Semaphore sem; |
| 6 | |
| 7 | static ~this() |
| 8 | { |
| 9 | if (sem !is null) sem.notify(); |
| 10 | } |
| 11 | |
| 12 | void main() |
| 13 | { |
| 14 | sem = new Semaphore; |
| 15 | auto thr = new Thread({assert(sem.wait(1.seconds));}); |
| 16 | thr.start(); |
| 17 | } |