Re: lock used in thread and by event
- From: "Jon Skeet [C# MVP]" <skeet@xxxxxxxxx>
- Date: Tue, 25 Sep 2007 05:17:41 -0700
On Sep 25, 12:54 pm, uupi_...@xxxxxxxxx wrote:
No, this is the issue: first thread is using a method X that uses
lock(X).
Second thread is fireing an event that executes first threads method
that also uses lock(X).
There's no such thing as "first thread's method" though.
So is this situation same like e.g. one and only thread is calling
lock(X) two times and it does not block?
I don't know - I'd have to see the code.
To clearify again ;) is Event call from one thread to another threads
method that uses lock(X) {...} like Java's ReentrantLock?
An event call doesn't change threads (unless you explicitly call
Invoke or something like that). But to reiterate, there's no such
thing as "another thread's method". Methods don't belong to threads.
And yes, locks are re-entrant.
Jon
.
- Follow-Ups:
- Re: lock used in thread and by event
- From: uupi_duu
- Re: lock used in thread and by event
- References:
- lock used in thread and by event
- From: uupi_duu
- Re: lock used in thread and by event
- From: Jon Skeet [C# MVP]
- Re: lock used in thread and by event
- From: uupi_duu
- Re: lock used in thread and by event
- From: Jon Skeet [C# MVP]
- Re: lock used in thread and by event
- From: uupi_duu
- lock used in thread and by event
- Prev by Date: Re: lock used in thread and by event
- Next by Date: Re: For future reference: nested classes and access modifiers (protected, protected internal)
- Previous by thread: Re: lock used in thread and by event
- Next by thread: Re: lock used in thread and by event
- Index(es):