I have one small confusion. i am using one static variable called status with property in c# as follows
private static bool status;
public static bool Status
{
get { return status; }
set { status = value; }
}
Now i have started 2 threads separately First thread sets the value using property for variable status as true/false Second thread gets the value using property for variable status.
Here in this scenario, i thought like what would happen
if first thread tries to update the value of variable status while second thread tries to read the value of variable status
Whether i need to use lock statement for this variable status inside property to handle thread synchronization or its not needed? Could anyone help me by clarifying this doubt?