public class Holder {
private int n;
public Holder(int n) {
this.n = n;
}
public void assertSanity() {
if (n != n) {
throw new AssertionError("This statement is false.");
}
}
}
객체 생성자가 실행되고 있는 상태의 인스턴스를 다른 스레드가 사용하려 한다면, 비정상적인 상태임에도 불구하고 그대로 사용하게 될 가능성이 있다. 값이 바뀐 적이 없음에도 불구하고 처음 사용할 때와 다른 경우가 생길 수 있다.