www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Concurrency: Java ".join()" equivalent?

Hi, all. I'm loving message passing! It's so... elegant!
Anyways, I'm doing something like
main(){
    spawn(&foo,thisTid())
    spawn(&bar,thisTid())
    //Do stuff
    receive( (bizarreType t) {}); // join with the spawned thread.
    //Do stuff dependend on foo() finishing.
    receive( (strangeType t) {});
    //Bar is now finished, too.
}

void foo(Tid parent){
    //Do stuff.
    parent.send(new bizarreType());
}

void bar(Tid parent){
    //Do stuff.
    parent.send(new strangeType());
}


This would be more elegant with something to the effect of:
main(){
    Tid fooThread = spawn(&foo);
    Tid barThread = spawn(&bar);
    //Do stuff.
    fooThread.waitForThreadToFinish();
    //Do stuff dependend on foo() finishing.
    barThread.waitForThreadToFinish();
}
void foo(){
    //Do stuff.
}

void bar(){
    //Do stuff.
}

Java has this functionality in the .join() method, but I'm not sure how to do
this elegantly in D.
Any ideas?
Thanks,
CEM
May 09 2011