In Java, a field doesn't need to be volatile if you access it only after joining on the thread that mutated it; the join enforces a happens before relationship.
What about in c#? With the below code, am I guaranteed to see the updated value of _value after calling Join() or do I need to make _value volatile ?
private String _value = "FOO"
public void Foo()
{
Thread myThread = new Thread(Bar);
myThread.Start();
myThread.Join();
Console.WriteLine("[Main Thread] _val = "+ _value);
}
public void Bar()
{
for(int i=0; i<1000; i++)
{
Console.WriteLine("Looping");
if(i==75)
{
_value="BAR";
}
}
Console.WriteLine("DONE Looping");
}
In my code snippet, will "BAR" always be printed?