added two implementations of wait and notify