aboutsummaryrefslogtreecommitdiff
path: root/libphobos/testsuite/libphobos.init_fini/thread_join.d
blob: b7700429bd406791cf9bd5040a0ea0c1387f1a02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Bugzilla 11309 - std.concurrency: OwnerTerminated message doesn't work
// We need to assure that the thread dtors of parent threads run before the thread dtors of the child threads.
import core.thread, core.sync.semaphore;

__gshared Semaphore sem;

static ~this()
{
    if (sem !is null) sem.notify();
}

void main()
{
    sem = new Semaphore;
    auto thr = new Thread({assert(sem.wait(1.seconds));});
    thr.start();
}