import core.thread.osthread : Thread; import std.stdio : writeln; __gshared static Thread th; __gshared static size_t tht; void run() { writeln("run"); while (tht == 0) {} } shared static this() { writeln("this"); th = new Thread(&run).start(); } shared static ~this() { writeln("~this"); tht = 1; } void main() { writeln("main"); }