fixed problem with wait and notify