GC and threads

Saaa empty at needmail.com
Sun Jan 28 12:44:16 PST 2007


> Saaa wrote:
>> Will a garbage collection sweep halt all threads momentarily?
>
> All threads created using std.thread, IIRC.
>
>> If so, isn't there a way around this?
>
> There is, don't use std.thread to start your thread ;). Be careful though: 
> threads the GC doesn't know about should never have the only reference to 
> an object allocated on the GC heap (i.e. allocated using a non-overloaded 
> 'new').
> In fact, it theoretically  shouldn't have *any* reference to an object 
> created by the GC, since the GC is allowed to move objects and can only 
> adjust references in the registers of a thread if it knows about the 
> thread. However, the current GC doesn't move objects, so for now that 
> should still be safe.

Yeah, I was searching for it, but couldn't find it... until like a minute 
after my post :)





More information about the Digitalmars-d mailing list