Hi Experts,
Can you please help me to find the answer of below questions.
1)What is the role of synobject in lock statement?
public class lockherper
{
private static object synobj=new object();
public void MyCriticalData()
{
lock (synobj)
{
}
}
}
2)Can we use value type as synobject?.If yes, then what are side effect of taking value type in synobject.
public class lockherper
{
private static int synobj=new int();
public void MyCriticalData()
{
lock ((object)synobj)
{
}
}
}
Thanks
Dinesh Sharma
What I have tried:
Can you please help me to find the answer of below questions.
1)What is the role of synobject in lock statement?
public class lockherper
{
private static object synobj=new object();
public void MyCriticalData()
{
lock (synobj)
{
}
}
}
2)Can we use value type as synobject?.If yes, then what are side effect of taking value type in synobject.
public class lockherper
{
private static int synobj=new int();
public void MyCriticalData()
{
lock ((object)synobj)
{
}
}
}
Thanks
Dinesh Sharma