12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- alias uint8 = ubyte;
- import std.stdio;
- import std.concurrency : spawn;
- import core.time : Duration, dur;
- import core.thread;
- void test1_worker(uint8 n){
- writeln("started worker = ", n);
-
- Thread.sleep(dur!"seconds"(120));
-
- writeln("stopped worker = ", n);
- }
- void test1_spawner(){
- uint8 i = 10;
-
- while(i > 0){
- spawn(&test1_worker, i);
-
- i--;
- }
- }
- /*
- // 1 OS process, 10 threads
- > make run
- ./vtest2
- started worker = 8
- started worker = 7
- started worker = 9
- started worker = 6
- started worker = 1
- started worker = 10
- started worker = 5
- started worker = 3
- started worker = 2
- started worker = 4
- stopped worker = 8
- stopped worker = 9
- stopped worker = 7
- stopped worker = 10
- stopped worker = 6
- stopped worker = 1
- stopped worker = 4
- stopped worker = 3
- stopped worker = 5
- stopped worker = 2
- hello here!
- */
|