(I'm interested in the .NET CLR)
What exactly happens when one thread modifies an object that refers to a variable while another thread executes a method on the original object?
For example, let's say that the type Foohas a variable of the “Bar” type Bar, and Bardoes not have state at the class level (at least for now, I would like this script to be simple):
foo.Bar = new Bar();
foo.Bar.SomeMethod();
Meanwhile, before that, execution ends ...
foo.Bar = new Bar();
What happens to a method that is executing (was?) Executing in Thread 1? Is everything you need to complete already on the stack?
Has this changed if, instead, in this case 2?
foo.Bar = null;