digitalmars.D.learn - How to terminate thread under module destructor?
- An Pham (23/23) Mar 09 import core.thread.osthread : Thread;
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"); }
Mar 09