Multithreading: Which lock object should i use?

added by baldi
9/6/2010 12:28:50 AM

1 Kicks, 89 Views

The lock keyword locks a specified code block so two threads can't process the same code block at the same time. When one threads exits the locked block, another thread can enter the locked code block. The Monitor class offers the same functionality, but you specifiy the start and end of the locked code block with Monitor.Enter and Monitor.Exit. For both techniques you need a variable to lock on, but what sort of variable should you use?


0 comments