Click to See Complete Forum and Search --> : Is CreateMutex() a atomic function?


coldstar
August 12th, 2009, 10:32 AM
I want to use CreateMutex() to prevent creating multiple instance of my application. But I'm not sure if two CreateMutex() could be called at the same time. If it can be happened then it can not perfectly prevent multiple instances to be created.

thanks.

Codeplug
August 12th, 2009, 11:01 AM
Yes - you can consider CreateMutex as being "atomic" with respect to other threads also calling CreateMutex with the same name.

gg

dc_2000
August 13th, 2009, 07:48 PM
Yes, any named object is unique (throughout the same desktop, I believe) as long as it's not closed.

Igor Vartanov
August 14th, 2009, 01:44 AM
But I'm not sure if two CreateMutex() could be called at the same time.Of course they could. And someone will definitely win the race. ;)