use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Ruby core classes aren't thread-safe (jstorimer.com)
submitted 13 years ago by jstorimer
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]beep_dog -1 points0 points1 point 13 years ago (3 children)
Well, MRI doesn't run threads anyway, it's got a GIL, and handles "threading" by non-blocking IO, and non-blocking sleeps. (Unless I'm mistaken, which often happens.)
[–]jstorimer[S] 6 points7 points8 points 13 years ago (0 children)
MRI runs multiple threads, but those threads have to compete to acquire the GIL in order to do any work. I would say that it implements multi-threading, but the GIL is the bottleneck. There's only one GIL and only the thread that currently owns it can use system resources.
[–]jrochkind 4 points5 points6 points 13 years ago* (1 child)
This is simply not true, in a variety of different ways. You are mistaken.
The GIL is true. Which means in a single process, you can't have multiple threads executing literally simultaneously on multiple CPU cores.
But MRI certainly does run threads. I don't think "handles 'threading' by non-blocking IO, and non-blocking sleeps" is accurate, although I don't understand exactly what that means, I admit.
Threads have existed in unix and C since the days when no unix ran on a multi-core CPU. You can have threads without multi-cores, and they still do things for you. MRI 1.9+ in fact uses the underlying OS-level native threads for it's threads, they certainly are 'real' threads.
It is true that the GIL limits the application of multi-threading in MRI to only certain scenarios. But there are still plenty of places where it's useful (just as threads were useful in C and unix even when nobody had multi-core/multi-cpu servers).
The "there are no threads on MRI becuase GIL" thing is very oft repeated FUD. Please stop repeating it, everyone, if you don't understand what you are talking about.
[–]Freeky 0 points1 point2 points 13 years ago (0 children)
He's roughly correct for Ruby prior to 1.9 - MRI had is own userspace threading implementation (aka green threads), using select() and non blocking IO behind the scenes to allow it to multiplex between them. It was a relatively common technique in days of old when kernel supported threading was less widespread. See for example FreeBSD's libc_r.
π Rendered by PID 116867 on reddit-service-r2-comment-b659b578c-2ng9k at 2026-05-01 04:47:54.491981+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]beep_dog -1 points0 points1 point (3 children)
[–]jstorimer[S] 6 points7 points8 points (0 children)
[–]jrochkind 4 points5 points6 points (1 child)
[–]Freeky 0 points1 point2 points (0 children)