alias uint8 = ubyte; import std.stdio; import std.concurrency : spawn; import core.time : Duration, dur; import core.thread; //void test1_worker(uint8 n){ void test1_worker(int n){ writeln("started worker = ", n); Thread.sleep(dur!"seconds"(120)); writeln("stopped worker = ", n); } void test1_spawner(){ uint8 i = 10; // 10 = 1.7 Mb RAM // 255 = 2.9 Mb RAM // 1000 = 6.6 Mb RAM // 10_000 = 55.1 Mb RAM // 100_000 = 180.3 -> 434.4 Mb RAM //int i = 100_000; // freeze with 180.3 -> 434.4 Mb RAM .. (( 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! */