Threads not garbage collected ?
David Nadlinger via Digitalmars-d
digitalmars-d at puremagic.com
Tue Feb 21 23:58:45 PST 2017
On Wednesday, 22 February 2017 at 07:14:27 UTC, Jonathan M Davis
wrote:
> In this particular case, the program would probably exit if you
> did
>
> void main()
> {
> {
> auto a = new A;
> }
>
> import core.memory;
> GC.collect();
> }
I very much doubt so. A Thread object isn't just a handle or
thread reference, but also encapsulates some of the
system/druntime state required to make threading work. Executing
Thread.~this() while a thread was still running would lead to a
crash.
(The tricky part is to make sure the Thread object becomes
eligible for collection once a thread has actually finished.)
— David
More information about the Digitalmars-d
mailing list