making some changes based on feedback from code review

The wait() notify() calls have been replaced with a CountDownLatch to address
the scenario in which notify() is invoked before wait(). JavaDoc has also been
added to explain usage.