race condition solution in package waitnotify.race