Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC#the CLR and managed executionSingle-choice MCQ

Two threads each declare `[ThreadStatic] static int counter;`. What does the CLR guarantee about the field's initial value the first time a NEW thread reads it?

class C { [ThreadStatic] static int counter = 100; public static int Read() => counter; } // Thread A triggers init -> sees 100 // Thread B (never ran initializer) -> sees 0