Even with the GVL, this counter ends well below 20000. What does that prove about the GVL's guarantees?
class Counter
attr_accessor :n
def initialize = @n = 0
def bump
v = @n
Thread.pass
@n = v + 1
end
end
c = Counter.new
20.times.map { Thread.new { 1000.times { c.bump } } }.each(&:join)
c.n # => far less than 20000