Hi Experts,
please look at this example,can someone tell me what is the scenario behind it,
Code:
class MyClass
{
private string m_sString = null;
public MyClass()
{
m_sString = "Hello";
}
void GetString1()
{
lock (this)
{
return m_sString;
}
}
void GetString2()
{
lock (m_sString)
{
return m_sString;
}
}
}
I know another thread can't access GetString1,I don't know what is the difference between lock(this) and lock(m_sString)?
Thanks in advance.
_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.