mutex

Thread-Safe Initialization of a Singleton

There are a lot of issues with the singleton pattern. I'm totally aware of that. But the singleton pattern is an ideal use case for a variable, which has only to be initialized in a thread safe way. From that point on you can use it without synchronization. So in this post I discuss different ways to initialize a singleton in a multithreading environment. You get the performance numbers and can reason about your uses cases for the thread safe initialization of a variable.

Read more
Comments 6Views: 6270

Prefer Locks to Mutexes

If the previous post showed something, it's, that you should use mutexes with great care. That's why you should wrap them in a lock.

Read more
Tags: lock, mutex
Comments 17Views: 2723

The Risks of Mutexes

Usage of mutexes seems extremely simple. There is a critical section in the code, which can only be accessed by a single thread at any point  of time. It's ensured by a mutex m. The calls m.lock() and m.unlock() guarantee this exclusivity. But, the devil is in the details.

Read more
Tags: mutex
Comments 1Views: 1562

My Newest E-Book

Latest comments

Subscribe to the newsletter (+ pdf bundle)

Blog archive

Source Code

Visitors

Today 346

All 278869

Currently are 139 guests and no members online