-1

for example--

Object obj = new Object();

then I lock one section with lock(obj)

and I lock in other section also lock(obj)

if one thread is in the first section, does that mean that the other section is also locked?

Onic Team
  • 1,562
  • 5
  • 26
  • 32

1 Answers1

2

Locking is done on an object, not on a section or location of the code. If one thread takes the lock in the first location, the second thread can't take it anywhere - neither in the same location and nor in any other location.

Mureinik
  • 277,661
  • 50
  • 283
  • 320