Consider the following code snippet within a class
private static Object _syncroot = new Object();
public void DoSomeWork()
{
// do some processing code
lock(_syncroot)
{
// process some shared data
}
// do some processing code
lock(_syncroot)
{
// do some further processing of shared data
}
}
If this code is being hit by multiple threads, if thread A gets into the second thread block locking against _syncroot, would this also effectively lock any threads from entering the first sync block until thread A has exited the second sync block?