Singleton and Local static object: - 12-28-2008 , 02:57 AM
Is the below code thread safe, in multithreaded environments will a race
condition happen as we are using static
Singleton* Singleton::Instance ()
static Singleton s;
Re: Singleton and Local static object: - 12-29-2008 , 11:49 AM
That particular code segment is thread-safe. However, if you want to actually update the contents of the Singleton class, you need
to make sure you write that code in a thread-safe manner.
"Alamelu" <Alamelu (AT) discussions (DOT) microsoft.com> wrote
Re: Singleton and Local static object: - 12-30-2008 , 04:57 PM
C++ makes no guarantees in multithreaded environments. So the
initialization of a static object could easily have a race condition. C++0x
will address parallel execution for the first time.
"Brian Muth" <bmuth (AT) mvps (DOT) org> wrote
|Thread Tools||Search this Thread|