今天看 OpenJDK 时发现这样一段 (已删减)
int status = pthread_mutex_lock(_mutex);
int anyWaiters = _nParked;
status = pthread_mutex_unlock(_mutex);
// Note that we signal() *after* dropping the lock for "immortal" Events.
// This is safe and avoids a common class of futile wakeups. In rare
// circumstances this can cause a thread to return prematurely from
// cond_{timed}wait() but the spurious wakeup is benign and the victim
// will simply re-test the condition and re-park itself.
// This provides particular benefit if the underlying platform does not
// provide wait morphing.
if (anyWaiters != 0) {
status = pthread_cond_signal(_cond);
}
注释说虚假唤醒是良性的能够理解,但不知道最后一句话是啥意思,particular benefit?求解释
signal 在 unlock 前和后有什么区别?