Created
          May 8, 2021 21:02 
        
      - 
      
 - 
        
Save 1502shivam-singh/44d6c778d8c997b99e0b0fdb900a6cee to your computer and use it in GitHub Desktop.  
    The most basic deadlock example (recursive)
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #include <iostream> | |
| #include <mutex> | |
| std::mutex mtx; | |
| void deadlock() { | |
| std::lock_guard<std::mutex> _mu(mtx); | |
| std::cout<<"Deadlock incoming\n"; | |
| deadlock(); | |
| } | |
| int main(){ | |
| deadlock(); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment