Lock statement - 2nd question

  • Thread starter Thread starter Roy Chastain
  • Start date Start date
R

Roy Chastain

The doc says that the same thread can acquire a lock more than once.

My testing STRONGLY suggests that the doc is incorrect. It appears that my thread is blocking on itself.

Can anyone confirm that the doc is right or wrong?

Thanks
 
I think I figured this one out.

I have a CAO that I am locking in the client code. My guess is that at this point the lock is actually taking place on the server
and because of the magic of remoting, it is actually taking place on different threads on the server.
 
Roy,

This is highly unlikely. The remoting infrastructure doesn't translate
locks across the app-domain boundary.

Can you show some code where this would not be the case?
 
Roy Chastain said:
The doc says that the same thread can acquire a lock more than once.

My testing STRONGLY suggests that the doc is incorrect. It appears
that my thread is blocking on itself.

Can anyone confirm that the doc is right or wrong?

The docs are absolutely right - and it's very easy to test this:

using System;

class Test
{
static void Main()
{
object obj = new object();

lock (obj)
{
lock (obj)
{
Console.WriteLine ("No blocking here!");
}
}
}
}
 
Back
Top