Project

General

Profile

Actions

Backport #5342

closed

ConditionVariable can wake a Thread that is no longer waiting on it

Added by mperham (Mike Perham) over 12 years ago. Updated almost 8 years ago.

Status:
Rejected
[ruby-core:39632]

Description

See gist at https://gist.github.com/1228184 for a reproducible test case.

Sequence is like this:

  • Main thread spawns Thread 1. Thread 1 pauses 0.5 seconds and then signals cond variable 1.
  • Main thread waits on cond variable 1 and times out after 0.3 seconds
  • Main thread spawns Thread 2. Thread 2 pauses 0.5 seconds and then signals cond variable 2.
  • Main thread waits on cond variable 2 with a timeout of 1.0 seconds.

I would expect this test to take 0.8 seconds. Instead the main thread is woken by the original cond variable 1 after 0.5 seconds total.

The code works as expected on JRuby 1.6.4.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0