[Issue 5157] thread_joinall() looks like it doesn't actually join all

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 3 07:56:20 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=5157


Steven Schveighoffer <schveiguy at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |schveiguy at yahoo.com
         Resolution|                            |INVALID


--- Comment #1 from Steven Schveighoffer <schveiguy at yahoo.com> 2010-11-03 07:55:06 PDT ---
The original code looks correct to me.  Rewritten in pseudocode:

while(true)
{
   nonDaemon = null;
   assign nonDaemon to first non-daemon thread in the list of threads;
   if(nonDaemon not found)
     // this means there are no non-daemon threads left
     return;
   nonDaemon.join();
}

The reason it is done this way instead of the way you suggest is because the
foreach is synchronized on a lock (to prevent threads coming/going while
iterating).  So you don't want to call join while inside the foreach loop.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list