added wait and notify