I have a thread that calls the wait method and can only be awoken when the notify method called from some other class:
wait
notify
class Threa
You could loop and wait until the total has been computed :
synchronized(b) { while (total == 0) { b.wait(); } }
You could also use a higher-level abstraction like a CountDownLatch.