Last active
September 27, 2020 14:03
-
-
Save aferust/c95082f5fcf764167c26006a60304a72 to your computer and use it in GitHub Desktop.
delayed ctrl 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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