static this() and Atomic Operations

Learn how shared static this() is used for single initialization and shared static ~this() can be used for single finalization. Also get an introduction to atomic operations in this lesson.

static this() and static ~this()

We have already discussed how static this() can be used for initializing modules, including their variables. Because data is thread-local by default, static this() must be executed by every thread so that module-level variables are initialized for all threads:

Get hands-on with 1200+ tech skills courses.