Make sure to really wait until being notified. The thread might be awakened (or interrupted) for other reasons than for triggering by notification so we loop until we get the notification. To also not loose a notification, we wait for a limited time only. In any case, the loop only exists when the trigger flag is set.