class C {
        int i;

        synchronized void inc() {
                i++;
        }
}

class ThreadC extends Thread {
        C c;
        int j;
        ThreadC(String id, C c) {
                super(id);
                this.c = c;
                start();
        }
        public void run() {
                for (int i = 0; i < 10000000; i++) {
                        c.inc();
                        j++;
                }
                System.out.println(getName() + ": j = " + j);
        }
}


class ProvaUno {
        public static void main(String[] args) throws InterruptedException {
                
                  C c = new C();
                  ThreadC[] t = new ThreadC[10];

                  for (int i = 0; i < 10; i++)
                        t[i] = new ThreadC("Thread " + i, c);

                  for (int i = 0; i < 10; i++)
                        t[i].join();
                  System.out.println("c.i = " + c.i);
        }
}


