Hi Keith,
"Keith Langer" <ta******@aol.com> wrote in message
news:15**************************@posting.google.c om...
Miha,
If writer switches to reader, then nothing could be writing, so it
wouldn't matter.
I am talking about two threads - one writer and one reader.
The real question is can I have one writer and one reader (which does not enumerate). Could you explain what non-atomic
operations occur when writing to or reading from a hashtable?
An atomic opertaion is the operation that can't be interupted.
As an example, assigning an integer is an atomic operation because it is
done in one procesor operation (at machine level).
So, it can't be interrupted by thread scheduler.
Assigning a string is not an atomic operation because it involves more than
one procesor's operation (allocating memory, copying chars, etc).
It *can* be interrupted by thread scheduler in the middle of assignment -
when part of the job is done and part not.
So, if you gonna read same string in the middle of assignment operation from
within another thread it will cause havoc because string will be in possibly
invalid state.
The same is true for hashtables - adding items is not an atomic operation.
HTH
--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com