According to me this is how the program execution is taking place:
First the two threads are started and then see a wait call thus started waiting for notificationin the wait set and then the third thread executes upto this statement:
System.out.println("Waiting for calculation...");
and then the main thread begins executing which then calls the calculator that notifies all the thread that are waiting.Because only the two threads are in wait set they get notified and print total, now the main thread terminates and the third waiting thread encounters the wait call and since it does not get any notification now,the program runs Indefinitely.
I tried my best to explain.I hope this helps.