In the following implementation of Singleton, is the instance constructor
guaranteed to execute only once regardless of how many threads try to
access it at one time?
class Test {
public static readonly Test Instance = new Test();
Test() {
// set up state. this mustn't execute more than once
}
}
guaranteed to execute only once regardless of how many threads try to
access it at one time?
class Test {
public static readonly Test Instance = new Test();
Test() {
// set up state. this mustn't execute more than once
}
}
Comment