에서 스레드 안전 정적 변수를 만들어야합니다. 질문보다 조금 복잡합니다.C# .Net
class A
{
static int needsToBeThreadSafe = 0;
public static void M1()
{
needsToBeThreadSafe = RandomNumber();
}
public static void M2()
{
print(needsToBeThreadSafe);
}
}
이제 M1()과 M2() 사이의 호출에서 'needsToBeThreadSafe'는 스레드 안전을 유지해야합니다.
() 원자 수? – Bombe
"스레드 안전"으로 무엇을 의미합니까? –