Is this a bug in the concurrency lib or am i using it incorrectly?
Gary Willoughby
dev at kalekold.net
Mon Jul 1 11:33:10 PDT 2013
I was hoping the below example would display 'hello world' but it
only displays 'hello'. Is this a bug in the concurrency lib or am
i using it incorrectly?
import std.stdio;
import std.concurrency;
void writer()
{
try
{
while (true)
{
receive((string s){
writefln(s);
});
}
}
catch (OwnerTerminated ex)
{
// die.
}
}
void sender(Tid writer)
{
send(writer, "world");
}
void main(string[] args)
{
auto writer = spawn(&writer);
send(writer, "hello");
spawn(&sender, writer);
}
More information about the Digitalmars-d-learn
mailing list