Thread-safety of static initializers in C#
问题 Everyone says static initializers are thread-safe, but I'm worried about a particular detail. Let's say I have static class MyStaticClass { public static readonly object myField = MyOtherClass.GetNewObject(); } static class MyOtherClass { public static object GetNewObject() { /* arbitrary code that returns a new object */ } } Which of the following does C# guarantee, when MyStaticClass.myField is not yet initialized? If threads 1 and 2 try to access myField together (in that order),