Add protection for thread spurious wakeups.