CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2009
    Posts
    2

    Is CreateMutex() a atomic function?

    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.

  2. #2
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Is CreateMutex() a atomic function?

    Yes - you can consider CreateMutex as being "atomic" with respect to other threads also calling CreateMutex with the same name.

    gg

  3. #3
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    894

    Re: Is CreateMutex() a atomic function?

    Yes, any named object is unique (throughout the same desktop, I believe) as long as it's not closed.

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Is CreateMutex() a atomic function?

    Quote Originally Posted by coldstar View Post
    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.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured