Re: hashtable - thread safety clarification
- From: Arne Vajhøj <arne@xxxxxxxxxx>
- Date: Mon, 16 Feb 2009 22:56:42 -0500
James wrote:
I read the following in the help for VS C# Express edition:
"Hashtable is thread safe for use by multiple reader threads and a single writing thread."
if I am using a hashtable just like described above, multiple threads read from in but only one thread changes it, should I still be declaring it as 'volatile'?
The statement you quote only covers the safety of the Hashtable's
internal structure - it does not cover thread safety in general.
Volatile will make changes visible to other threads, but that
may not be sufficient for thread safety in your context.
Using lock on a shared object by all threads is most likely
to be most robust way of making your app thread safe.
Arne
.
- References:
- hashtable - thread safety clarification
- From: James
- hashtable - thread safety clarification
- Prev by Date: Re: Merging code.
- Next by Date: Re: hashtable - thread safety clarification
- Previous by thread: Re: hashtable - thread safety clarification
- Next by thread: List<T> : I have a two column List and just want to pass one column in an array to a method.
- Index(es):
Relevant Pages
|