class C {
        int a;
        int b;

        synchronized void foo() {
                int y = a + 10;
                for (int i = 0; i < 1000000; i++);

                a = y;
                b++;
        }
}

class ThreadC extends Thread {
        C c;
        ThreadC(String id, C c) {
                super(id);
                this.c = c;
        }

        public void run() {
                for (int i = 0; i < 10000; i++)
                        c.foo();
        }
}


class ProvaInterf {
        public static void main(String[] args) throws InterruptedException {
                C c = new C();
                ThreadC t1 = new ThreadC("Thread 1", c);
                ThreadC t2 = new ThreadC("Thread 2", c);
                t1.start();
                t2.start();

                t1.join();
                t2.join();
                System.out.println("c.a = " + c.a + ", c.b = " + c.b);
        }
}
