Skip to content

Instantly share code, notes, and snippets.

@aferust
Last active September 27, 2020 14:03
Show Gist options
  • Save aferust/c95082f5fcf764167c26006a60304a72 to your computer and use it in GitHub Desktop.
Save aferust/c95082f5fcf764167c26006a60304a72 to your computer and use it in GitHub Desktop.
delayed ctrl 2
import std.stdio;
import std.concurrency;
import core.thread;
void main() {
int k;
while(true){
auto childTid = spawn(&spawnedFunc, thisTid);
Thread.sleep(10.msecs);
send(childTid, k);
k++;
if(k==10) k = 0;
}
//writeln("main is done.");
}
static void spawnedFunc(Tid ownerTid)
{
receive((int v){
Thread.sleep(5000.msecs);
writeln(v);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment