001package observer.one;
002public class Main {
003        public static void main(String[] argv) {
004                Int c = new Int();
005                Runnable r1 = new M(c);
006                Runnable r2 = new N(c);
007                for (int i=0; i<10000; i++) {
008                        r1.run();
009                        r2.run();
010                }
011        }
012}
013class Int {
014        private int v;
015        public int get() { return v; }
016        public void inc() { v++; }
017        public void dec() { v--; }
018}
019class M implements Runnable {
020        private Int c;
021        public M(Int c) { this.c = c; }
022        public void run() {
023                c.inc();
024                c.inc();
025                c.dec();
026        }
027}
028class N implements Runnable {
029        private Int c;
030        public N(Int c) { this.c = c; }
031        public void run() {
032                for (int i=0; i<50; i++) {
033                        if (i%3==0) {
034                                c.dec();
035                        } else {
036                                c.inc();
037                        }
038                }
039        }
040}