001package singleton.lazy;
002public class S {
003        private S() {}
004        static private SState state;
005        static public int inc() {
006                if (state == null) {
007                        if ("linux".equals(System.getProperty("os.name"))) {
008                                state = new SLinux();
009                        } else {
010                                state = new SOther();
011                        }
012                }
013                return state.inc();
014        }
015
016        static private interface SState {
017                public int inc();
018        }
019        static private class SLinux implements SState {
020                private int i;
021                public int inc() {return ++i;}
022        }
023        static private class SOther implements SState {
024                private int i;
025                public int inc() {return --i;}
026        }
027}