Re: Synchronized Collection<T> Recommendation
- From: Chris Chilvers <keeper@xxxxxxxxxxx>
- Date: Sun, 30 Apr 2006 19:57:19 +0100
All this locking will however slow things down for such things as
for (int i = 0; i < list.Count; i++) ...
Which will now lock every time it reads something, and what if:
Thread A increments i to the last element (count-1)
Thread B deletes the last element
Thread A tries to read the last element
In these cases I'd favor having an unsyschronized collection and having
some specified way to obtain the collection exclusivly.
It just seems to me that syncronization on such things as a collection
are very much dependent upon what the collection is storing and what the
data is being used for. Without knowing the specific case it will be
used it just seems like one cannot reliably choose the locking mechanism
or guarantee that it will even work correctly as shown in the previous
example.
.
- Follow-Ups:
- Re: Synchronized Collection<T> Recommendation
- From: Michael Primeaux
- Re: Synchronized Collection<T> Recommendation
- References:
- Synchronized Collection<T> Recommendation
- From: Michael Primeaux
- Re: Synchronized Collection<T> Recommendation
- From: Chris Chilvers
- Re: Synchronized Collection<T> Recommendation
- From: Michael Primeaux
- Re: Synchronized Collection<T> Recommendation
- From: William Stacey [MVP]
- Re: Synchronized Collection<T> Recommendation
- From: Michael Primeaux
- Re: Synchronized Collection<T> Recommendation
- From: William Stacey [MVP]
- Re: Synchronized Collection<T> Recommendation
- From: Michael Primeaux
- Synchronized Collection<T> Recommendation
- Prev by Date: Re: Synchronized Collection<T> Recommendation
- Next by Date: Re: Error 500 on oXmlHTTP.Send
- Previous by thread: Re: Synchronized Collection<T> Recommendation
- Next by thread: Re: Synchronized Collection<T> Recommendation
- Index(es):
Relevant Pages
|
|