Re: Locking Question around hashtable
- From: "Nick Hounsome" <nh002@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 13 Feb 2006 13:15:04 GMT
"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:1139836296.856759.110660@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Nick Hounsome wrote:
If you've just got a single writer and multiple readers, the
documentation states that you don't need any locking.
Which documentation?
QUOTE
Thread Safety
To support one or more writers, all operations on the Hashtable must be
done
through the wrapper returned by the Synchronized method.
UNQUOTE
Good question. I *know* that the documentation did at one stage say
that it was safe for a single writer and multiple readers - but I can't
find it now :(
(I seem to remember that at the time that it said it was safe in that
way, the Thread Safety section itself was the standard "instance
members aren't threadsafe" docs, so it was already self-contradictory.)
You should be OK(ish) provided that you don't add or remove items.
Reading or changing (h[a]=b) should probably be alright but things would go
horribly wrong if a bucket was added or an element chained whilst a read was
in progress without some locking
.
- Follow-Ups:
- Re: Locking Question around hashtable
- From: Jon Skeet [C# MVP]
- Re: Locking Question around hashtable
- References:
- Locking Question around hashtable
- From: akantrowitz
- Re: Locking Question around hashtable
- From: Jon Skeet [C# MVP]
- Re: Locking Question around hashtable
- From: Nick Hounsome
- Re: Locking Question around hashtable
- From: Jon Skeet [C# MVP]
- Locking Question around hashtable
- Prev by Date: Re: Locking Question around hashtable
- Next by Date: XmlNode to XmlDocument.
- Previous by thread: Re: Locking Question around hashtable
- Next by thread: Re: Locking Question around hashtable
- Index(es):
Relevant Pages
|