On Wednesday, 22 February 2017 at 05:28:17 UTC, Alex wrote:
[...]

In both gdc and dmd I need to use manually delete this object or the program is blocked after main. Is by design ?

Yes, it's documented here[1] (others have already replied on the GC subject, so I won't go into that). If you want a thread to be forcibly terminated instead of preventing program termination you need to set `thread.isDaemon = true`.

It seems undesirable, as the thread can be many layers of encapsulation down, and they all need manual deletes.

It's highly desirable to not have the program terminate when there's still work to be done on some critical non-main thread, so the druntime split into daemon vs non-daemon threads makes sense. Whether new threads should be daemonized by default (as opposed to preventing program termination by default) is an arbitrary decision. In your case, just set `isDaemon = true` for your threads and you should be good.

[1] https://dlang.org/phobos/core_thread.html#.Thread.isDaemon

Reply via email to