Silly question I am sure, and I'm almost positive I know the answer to this, but, if I have a static method that has a return type that is a non-static class type, when the static method is executing and after the method has initialized the class to return (but has not returned it yet), without locking the method it IS thread safe since it is not using a shared object and if the static method is called in succession by many threads, each will return their own correct "version" of the class object, correct?
For example (this is really quick so just follow the general idea):
public class myClass
{
int i;
string s;
public myClass ()
{
}
}
public class myOtherClass
{
public myOtherClass()
{
}
public static myClass myMethod(int i, string s)
{
myClass mc = new myClass();
mc.i = i;
mc.s = s;
return mc;
}
}
If multiple threads call myMethod() at the same time, is that thread safe? I would say yes. Anyone disagree?