updated notify-and-wait