jeudi 1 décembre 2016

why double lock c++11 mutex didn't cause dead lock? (compiler g++ 4.8.5 in centos 3.10.0-327.36.3.el7.x86_64)

I test c++11 mutex in my centos computer,i try to double lock this mutex to make deadlock . But after i running it, everything is fine and no deadlock .

#include <thread>
#include <mutex>
#include <iostream>
std::mutex m;
int main()
{
  m.lock();
  m.lock();
  std::cout<<"i am ok"<<std::endl;

  return 0;  
}

[zzhao010@localhost shareLibPlay]$ ./3.out

i am ok

Aucun commentaire:

Enregistrer un commentaire