I want to do this:
import core.thread.osthread : Thread;
void main() {
shared(Thread) thread1 = new Thread({
// Do stuff for a while...
});
auto thread2 = new Thread({
// ...
if(thread1.isRunning)
// Do a thing.
else
// Do a different thing.
// ...
});
auto thread3 = new Thread({
// ...
if(thread1.isRunning)
// Do a thing.
else
// Do a different thing.
// ...
});
}
However, I get various compile-time errors when I try to write
code like this because nothing in the Thread API is annotated
`shared`. Are Thread objects really not thread-safe, and if so
what is the correct way to synchronize access to one?
(The documentation for core.thread is broken right now, with dead
links and at least one reference to an example that doesn't
actually appear anywhere on the page.)