xref: /netbsd-src/external/gpl3/gcc/dist/libphobos/testsuite/libphobos.thread/join_detach.d (revision b1e838363e3c6fc78a55519254d99869742dd33c)
1 import core.thread;
2 import core.sync.semaphore;
3 
4 __gshared Semaphore sem;
5 
thread_main()6 void thread_main ()
7 {
8     sem.notify();
9 }
10 
main()11 void main()
12 {
13     auto th = new Thread(&thread_main);
14     sem = new Semaphore();
15     th.start();
16     sem.wait();
17     while (th.isRunning()) {}
18     destroy(th); // force detach
19     th.join();
20 }
21