Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardRubythe GVL global VM lockSingle-choice MCQ

This program spawns 4 threads doing CPU-bound integer math on MRI (CRuby) and times them. Compared with running the same total work in a single thread, what is the expected wall-clock result and why?

require 'benchmark' def work; x=0; 30_000_000.times { x += 1 }; x; end puts Benchmark.realtime { 4.times.map { Thread.new { work } }.each(&:join) }