Re: Threading newbie: Lock statement
- From: Arne Vajhøj <arne@xxxxxxxxxx>
- Date: Sun, 05 Nov 2006 21:11:32 -0500
Jan wrote:
Does the "lock" statement lock the "ressource" or the code section (like a critical section)?
Let me elaborate: I have two threads accessing the same ressource, but from *different* parts of the code. Can I use the lock statement to synchronise access, or can I only use lock when the threads access the ressource from the *same* part of he code (critical section). MSDN is somewhat unclear about this.
You can lock on the same object from different code
and achieve the desired synchronization.
But remember - it is still 100% cooperative locking.
Arne
.
- Follow-Ups:
- Re: Threading newbie: Lock statement
- From: Jan
- Re: Threading newbie: Lock statement
- References:
- Threading newbie: Lock statement
- From: Jan
- Threading newbie: Lock statement
- Prev by Date: Re: Why does this test for null fail?
- Next by Date: Re: Threading newbie: Threads on instance methods
- Previous by thread: Threading newbie: Lock statement
- Next by thread: Re: Threading newbie: Lock statement
- Index(es):
Relevant Pages
|