xref: /netbsd-src/external/gpl3/gcc.old/dist/libphobos/testsuite/libphobos.init_fini/thread_join.d (revision 627f7eb200a4419d89b531d55fccd2ee3ffdcde0)
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 import core.stdc.stdio;
5 
6 __gshared Semaphore sem;
7 
~this()8 static ~this()
9 {
10     if (sem !is null) sem.notify();
11 }
12 
main()13 void main()
14 {
15     sem = new Semaphore;
16     auto thr = new Thread({assert(sem.wait(1.seconds));});
17     thr.start();
18 }
19