Do threads 'end' themselves using core.thread?

Sean Kelly sean at invisibleduck.org
Mon Jul 22 09:57:48 PDT 2013


On Jul 22, 2013, at 9:45 AM, "Alex Horvat" <alexh at gmail.com> wrote:

>> ....
>> When a detached thread terminates, its resources are auto- matically released back to the system:"
> 
> Sounds like I can call Thread.getThis().thread_detachThis() from within DelayedHideTitle() and that will make the thread detached and therefore it will destroy itself properly.

Only call thread_detachThis() if you initialized the thread object via thread_attachThis().  Otherwise just discard the reference and let it clean itself up.  The reason for the "do not delete" restriction is because the thread objects are tracked internally by the GC, and they must remain in a correct state until the GC has recognized that they have terminated.


More information about the Digitalmars-d-learn mailing list