class TotalEarning extends Thread {
int earning = 0;
public void run() {
synchronized (this) {
for (int i = 0; i < 10; i++) {
earning += 100;
}
this.notify();
}
}
}
public class MovieBookApp3 {
public static void main(String[] args) {
TotalEarning te = new TotalEarning();
te.start();
synchronized (te) {
try {
te.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Total Earning = " + te.earning);
}
}
}