public class ThreadA {
    
    public ThreadA() {
        ThreadB b = new ThreadB();
        b.start();

        synchronized(b){
            try{
                System.out.println("Esperando a que termile el hilo b ...");
                b.wait();
            }catch(InterruptedException e){
                e.printStackTrace();
            }
 
            System.out.println("Total is: " + b.total);
        }        
    }
    
    class ThreadB extends Thread{
        int total=0;
        @Override
        public void run(){
            synchronized(this){
                for(int i=0; i<100 ; i++){
                    total += 1;
                }
                notify();
            }
        }
    }   
    
    public static void main(String[] args){
        new ThreadA();
    }
}
