Endless static this call when used a thread in it
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jan 15 06:29:26 PST 2015
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
More information about the Digitalmars-d-learn
mailing list