C
Carlos Kirkconnell
I'm programming a multi - threaded application using C#. I have two
questions regarding to the use of threads
1- I have a Hashtable that will have multiple writters and multiple readers.
I used the synchronized method to get a synchronized Hashtable. The
documentation says that enumerating is not a thread safe operation; even
using a synchronized Hashtable. The Hashtable has a "ContainsKey" method, is
this method thread safe? Does the "ContainsKey" method internally enumerate
the keys from the Hashtable in such a way that it needs the Hashtable to be
locked in order to be thread safe?
2. Threads have a Suspend method, which sleeps the thread until another
thread wakes it up using the Resume method. After the Suspend method is
called, the thread doesn't immeadiatelly go to the ThreadState.Suspended
state, it first passes through the ThreadState.SuspendRequested state, and
then it goes through the ThreadState.Suspended state. What will happen if
the resume method is called on a thread that is in the
ThreadState.SuspendRequested state? Will there be any problem?
Thanks for considering my questions
questions regarding to the use of threads
1- I have a Hashtable that will have multiple writters and multiple readers.
I used the synchronized method to get a synchronized Hashtable. The
documentation says that enumerating is not a thread safe operation; even
using a synchronized Hashtable. The Hashtable has a "ContainsKey" method, is
this method thread safe? Does the "ContainsKey" method internally enumerate
the keys from the Hashtable in such a way that it needs the Hashtable to be
locked in order to be thread safe?
2. Threads have a Suspend method, which sleeps the thread until another
thread wakes it up using the Resume method. After the Suspend method is
called, the thread doesn't immeadiatelly go to the ThreadState.Suspended
state, it first passes through the ThreadState.SuspendRequested state, and
then it goes through the ThreadState.Suspended state. What will happen if
the resume method is called on a thread that is in the
ThreadState.SuspendRequested state? Will there be any problem?
Thanks for considering my questions