473,387 Members | 1,757 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,387 software developers and data experts.

Threads, lock, many readers, one exclusive writer

Hi,

I am so far familiar with the C# lock keyword, which I understand
prevents any other thread from entering the portion of code which is
locked, assuming you are locking the same object instance.

I have a cache of data which initially I locked when I write to it,
and I locked the same object for any reading.

But this will soon become a performance issue, as many threads need to
read it concurrently.

What is the optimal approach?

thanks!

Tim
Nov 16 '05 #1
1 1665
Hi Tim,

You could try a ReaderWriter lock to see if it improves performance in your
scenario:

http://msdn.microsoft.com/library/de...classtopic.asp

Joe
--
http://www.csharp-station.com

"Tim Smith" <ti*******@hotmail.com> wrote in message
news:a7**************************@posting.google.c om...
Hi,

I am so far familiar with the C# lock keyword, which I understand
prevents any other thread from entering the portion of code which is
locked, assuming you are locking the same object instance.

I have a cache of data which initially I locked when I write to it,
and I locked the same object for any reading.

But this will soon become a performance issue, as many threads need to
read it concurrently.

What is the optimal approach?

thanks!

Tim

Nov 16 '05 #2

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

Similar topics

3
by: Jon Perez | last post by:
Is it safe to not put a lock on an object if it will always be read-only in other threads and will only ever be written to in just one and always the same one thread?
2
by: PAzevedo | last post by:
I have this Hashtable of Hashtables, and I'm accessing this object from multiple threads, now the Hashtable object is thread safe for reading, but not for writing, so I lock the object every time I...
1
by: jj_online | last post by:
This is not a C++ specific issue. However, I am trying to implement a readwritelock in C++ and hence would like to get help from this group. a readwritelock allows shared lock among all readers...
1
by: Peter | last post by:
Hi, I have a Dictionary<key, valuewhich is accessed by three threads. One thread puts my value objects in the dictionary (occasionally), and also updates the contents of existing value objects -...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.