The lock statement compiles down to the static Monitor class. In other words:
lock([SOME OBJECT])
{
// execute code
}
.. is equivalent to
Monitor.Enter([SOME OBJECT])
try
{
// execute code
}
finally
{
Monitor.Exit([SOME OBJECT]);
}
The monitor class provides more detailed control, but it's useful to know that for simple cases like the one above, they amount to the same thing.