My question is, if I have two critical paths within two separate methods, does the lock in the second method respect the lock in the first method?
As an example in the dummy code below if method1 is called by thread A, and method2 is called by thread B, does thread B wait for thread A to release the lock before entering the critical path in method2?
private static readonly object mylock = new object(); public void method1() { lock(mylock) { // critical path 1 } } public void method2() { lock(mylock) { // critical path 2 } }
lock objectis same