473,385 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Lock statement - 2nd question

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
-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
http://www.kmsys.com
Nov 17 '05 #1
3 1006
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.

On Thu, 14 Jul 2005 14:46:30 -0400, Roy Chastain <ro*@kmsys.com> wrote:
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
-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
http://www.kmsys.com


-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
http://www.kmsys.com
Nov 17 '05 #2
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?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Roy Chastain" <ro*@kmsys.com> wrote in message
news:8d********************************@4ax.com...
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.

On Thu, 14 Jul 2005 14:46:30 -0400, Roy Chastain <ro*@kmsys.com> wrote:
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
-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
http://www.kmsys.com


-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
http://www.kmsys.com

Nov 17 '05 #3
Roy Chastain <ro*@kmsys.com> wrote:
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!");
}
}
}
}

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Rich Sienkiewicz | last post by:
Some classes, like Queue and SortedList, have a Synchronized method which gives a thread safe wrapper object for these classes. But the lock() statement does the same thing. Is there any rules as to...
7
by: Sunny | last post by:
Hi, I can not understend completely the lock statement. Actally what is locked: 1. the part of the code between {...} or 2. the object in lock() In the docs is written: for 1: The lock...
2
by: adri4n | last post by:
as wat ive mentioned in the title.. im would like to know whether the a particular record/table is being locked in my program. some of the methods which i would like to develop are as below: ...
17
by: djc | last post by:
I got great info on related question previously. This link <http://www.yoda.arachsys.com/csharp/threads/volatility.shtml> from Brian Gideon was especially informative. 1) the lock statement does...
0
by: cwho.work | last post by:
Hi! We are using apache ibatis with our MySQL 5.0 database (using innodb tables), in our web application running on Tomcat 5. Recently we started getting a number of errors relating to...
5
by: jeff.ranney | last post by:
Hi all. I wrote this C# code: lock(this) { / /write to a file }
94
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock...
12
by: Zytan | last post by:
I have a Timer class set to trigger every second. The Tick function that is called every second uses a lock to prevent multiple ticks from executing the same code at the same time. The code...
2
by: Tom P. | last post by:
I have a class that ahs several methods. It pulls from a queue so it has to be singleton at that point. The question I have is: does the lock{} statement work across methods? If I have A(), B(),...
0
by: senthiltkp | last post by:
Hi, I'm new to DB2 and have little knowledge on database. i'm facing a Spin lock issue in db2.. Thread here am talking is Java thread..(Sepearte process) The spin Lock is acquired to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.