Cannot get thread ID with Thread.getThis() in specific callback functions on Windows

Mike Parker aldacron at gmail.com
Mon Dec 6 12:47:32 PST 2010


On 12/7/2010 2:10 AM, Haruki Shigemori wrote:
> (2010/12/06 16:59), Denis Koroskin wrote:
>> Because D runtime doesn't know about the newly created thread, and
>> static constructors weren't called. Try calling the following in your
>> callbacks:
>>
>> if (Thread.getThis() is null) thread_attachThis(); // if
>> (dont_know_about_this_thread) initialize_it();
>
> Wow... Is this D's design?
> I want phobos or druntime to take care of this problem.
> Is it difficult?

The problem is that the thread is created outside of druntime, internal 
to the Windows API. How is druntime to know about it unless you tell it?


More information about the Digitalmars-d mailing list