public static int getState() {
        if (STATE == 0) {
            synchronized (DoubleCheckedInt.class) {
                if (STATE == UNINITIALIZED_STATE) {
                    STATE = ONGOING_INITIALIZATION;
                    long r = System.nanoTime();
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                    }
                    if (r % 2 == 0) {
                        STATE = SUCCESS;
                    } else {
                        STATE = FAILURE;
                    }
                }
            }
        }
        return STATE;
    }
This class demonstrates that threads accessing the STATE variable always see a consistent value. 

During ongoing initialization the observed value is either ONGOING_INITIALIZATION
or one of {SUCCESS, FAILURE}. 

Post initialization the observed value is always one of  {SUCCESS, FAILURE}.

See also http://jira.qos.ch/browse/SLF4J-167 

@author ceki
slf4j-api/src/test/java/org/slf4j/basicTests/DoubleCheckedInt.java