C++ (Qt)mutex mut_a;int a = 0; mutex mut_b;int b = 0; void thread1(){ mut_a.lock(); if( a == 100500 ) { mut_b.lock(); b = -100500; mut_b.unlock(); } mut_a.unlock();} void thread2(){ mut_b.lock(); if( b == 1 ) { mut_a.lock(); a = 0; mut_a.unlock(); } mut_b.unlock();}