On 1/13/15 8:56 AM, tcak wrote:

When I defined static init with shared

public shared static this()

it works normal now. But it doesn't explain above issue. What's the
relation between a new thread and a module's initialiser?

In case it's not clear -- shared static this runs ONCE at the beginning of the program (before main() starts), static this runs for EVERY thread that starts, before the thread starts execution.

The reason is that "static this" initializes thread local data. "shared static this" initializes global data (i.e. shared and __gshared).

Hope this helps.

-Steve

Reply via email to