Thread fails to start

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Jan 1 21:37:24 PST 2011


On 01/01/2011 06:02 PM, Adam Conner-Sax wrote:
> As a way to learn D, I am writing a quick test setup for examining different
> ways of passing data from one set of threads to another.  I am trying a few
> kinds of queues (resizeable array with locking, linked list with locking and
> lockfree with cas) and trying to also add message passing and then compare
> performance.
>
> Anyway, I'm running into an odd case where a thread fails to start.  The code
> simply hangs in the Threadgroup.create(...) call. I am printing (with
> unbuffered i/o) right before the call to "create" and then as soon as the
> threadfunction starts so as far as I can tell, the "create" call is made but
> the threadfunc never starts and "create" never returns.
>
> It's repeatable but doesn't happen every time the queue is used. It happens
> sometimes when the queue is locking and sometimes when it is lockfree. I'd be
> happy to post code but for now I thought I'd just see if anyone can think of
> why that might happen or can provide some ideas for how to debug it.
>
> The code always starts the one consumer thread (via spawn. I'm learning!),
> then loops over the producers and creates them in a threadgroup just so I can
> do a "joinAll" to wait for them to finish.  Also, when the problem occurs,
> it's always the first producer thread that fails.  I never get 2 out of 4
> started, e.g.
>
> I am truly enjoying learning D.  Coming from a C++ and C# background, it's a
> pleasure.
>
> Any ideas would be appreciated.
>
> Thanks!
>
> Adam

Welcome. I suggest you post some code to serve as a basis for suggestions.

Andrei


More information about the Digitalmars-d mailing list