Z
Zeng
Hello,
If I have an object that exposes many methods which don't change anything
about the object (at least I'm not aware in terms of implementation of the
..net class). The methods are called by many threads at the same time. What
sort of things that I need to do to make sure the methods and the class are
multi-thread safe? I thought I don't need to do anything but I might be
wrong. For example, I remember reading from some help file that specifically
which multi-thread scenarios are safe for each method (can't find it right
now)
Basically, is this class multi-thread safe if no threads will be modifying
the Hashtable objects, it only loops through etc...
class A
{
static private A s_onlyInstance = new A();
static public A GetInstance() { return s_onlyInstance; }
private A() { }
private Hashtable m_hash1 = ....;
private Hashtable m_hash2 = ....;
public Hashtable Hash1{ get { return m_hash1; } }
public Hashtable Hash2{ get { return m_hash2; } }
}
Thanks!
zeng
If I have an object that exposes many methods which don't change anything
about the object (at least I'm not aware in terms of implementation of the
..net class). The methods are called by many threads at the same time. What
sort of things that I need to do to make sure the methods and the class are
multi-thread safe? I thought I don't need to do anything but I might be
wrong. For example, I remember reading from some help file that specifically
which multi-thread scenarios are safe for each method (can't find it right
now)
Basically, is this class multi-thread safe if no threads will be modifying
the Hashtable objects, it only loops through etc...
class A
{
static private A s_onlyInstance = new A();
static public A GetInstance() { return s_onlyInstance; }
private A() { }
private Hashtable m_hash1 = ....;
private Hashtable m_hash2 = ....;
public Hashtable Hash1{ get { return m_hash1; } }
public Hashtable Hash2{ get { return m_hash2; } }
}
Thanks!
zeng