# MRI-4 thread scheduling vs Timeout.timeout

**URL:** <https://www.ruby-forum.com/t/mri-4-thread-scheduling-vs-timeout-timeout/268217>\
**Category:** Ruby\
**Created:** [March 13, 2026, 8:22am UTC](https://www.ruby-forum.com/t/mri-4-thread-scheduling-vs-timeout-timeout/268217 "2026-03-13T08:22:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![duck2duck](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4bbf92/32.png) [@duck2duck](https://www.ruby-forum.com/u/duck2duck)\
**Post date:** [March 13, 2026, 8:22am UTC](https://www.ruby-forum.com/t/mri-4-thread-scheduling-vs-timeout-timeout/268217/1 "2026-03-13T08:22:19Z")

</div>

I recently learned about timeout (forum does not allow me to link to github).  
I read into its source code - it uses Ractor features, Fiber features and Thread features – the code is too clever for me to understand.

I have had the assumption that MRI-4 (ruby-4.0.1) does not preempt threads. Here is an example code that underpins my mental modell

```auto
def cpu_load()
  i=0
  while
    Math.sqrt(i)
    puts "t=#{Thread.current} i=#{i}" if i%400_000==0
    i += 1
  end
end

thread_list=[]
thread_list << Thread.new() do
  cpu_load
end
thread_list << Thread.new() do
  cpu_load
end

thread_list.each do
  _1.join
end

```

If you run the example, MRI-4 never switches the currently executing thread. So how does `Timeout.timeout` achieve to get scheduled?
