Added synchronized blocks with wait() , notify()