Boost logo

Boost Users :

Subject: Re: [Boost-users] thread-safe initialization for singleton
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2010-08-22 06:59:46

Le 22/08/2010 11:00, Kraus Philipp a écrit :

> I have written my own random class, in which I use a static
> boost::mt19937. On a single thread always works fine, but on multithread
> I get race condition errors. So I would like to create a static member
> over all threads.

static data members are initialized before main.
Your problem is not concurrent initialization, it's concurrent access to
the same object.

It has nothing to do whatsoever with only initializing a singleton once.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at