001package singleton.pub2;
002public interface S {
003        public static final S instance = SFactory.newS();
004        public int inc();
005}
006class SFactory {
007        static S newS() {
008                if ("linux".equals(System.getProperty("os.name")))
009                        return new SLinux();
010                else
011                        return new SOther();
012        }
013}
014final class SLinux implements S {
015        private int i;
016        public int inc() {return ++i;}
017}
018final class SOther implements S {
019        private int i;
020        public int inc() {return --i;}
021}