Threads not garbage collected ?

Chris Wright via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 22 20:57:14 PST 2017


The thread you created holds a reference to the `class A` object, so that 
object can't be collected.

This is what you probably want. As soon as the object is collected, its 
memory can be reused. But the thread still has a reference to it, so it 
can modify and read that memory. And whoever the GC handed that memory can 
modify and read it. In short, data corruption.


More information about the Digitalmars-d mailing list