# Threading model

**URL:** <https://www.ruby-forum.com/t/threading-model/183460>\
**Category:** IronRuby\
**Created:** [February 14, 2010, 10:19pm UTC](https://www.ruby-forum.com/t/threading-model/183460 "2010-02-14T22:19:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Orion\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/65b543/32.png) [@Orion\_E](https://www.ruby-forum.com/u/Orion_E)\
**Post date:** [February 14, 2010, 10:19pm UTC](https://www.ruby-forum.com/t/threading-model/183460/1 "2010-02-14T22:19:34Z")

</div>

Here is what I _think_ happens:

- Thread.new and the other ruby threading methods from the ruby  
standard  
library will create and run on new CLR threads, but there is ‘global  
interpreter lock’ type thing to emulate MRI
- I can sidestep the GIL by explicitly using underlying CLR threading  
methods

This is based entirely on speculation and “I thought I saw something  
about  
it once upon a time”  
Is there a page that explains what the threading model of IronRuby is? I  
would be happy to write one up on the wiki, but I have no idea what is  
actually going on.

Thanks, Orion.

---

<div class="post-metadata">

**Author:** ![Orion\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/65b543/32.png) [@Orion\_E](https://www.ruby-forum.com/u/Orion_E)\
**Post date:** [February 14, 2010, 11:17pm UTC](https://www.ruby-forum.com/t/threading-model/183460/2 "2010-02-14T23:17:31Z")

</div>

IronRuby maps Ruby’s green threads directly to CLR threads, and there is  
no GIL.

The best documentation is just to look through  
IronRuby.Builtins.ThreadOps[http://github.com/ironruby/ironruby/blob/master/Merlin/Main/Languages/Ruby/Libraries.LCA\_RESTRICTED/Builtins/ThreadOps.cs](http://github.com/ironruby/ironruby/blob/master/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ThreadOps.cs)  
=P. Here’s the first comment:

```
/// Ruby threads are represented by CLR thread objects 

```

(System.Threading.Thread).  
/// Ruby 1.8.N has green threads where the language does the thread  
scheduling.  
/// We map the green threads directly to CLR threads.

~js

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Orion E.  
Sent: Sunday, February 14, 2010 1:19 PM  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] Threading model

Here is what I _think_ happens:

- Thread.new and the other ruby threading methods from the ruby  
standard library will create and run on new CLR threads, but there is  
‘global interpreter lock’ type thing to emulate MRI
- I can sidestep the GIL by explicitly using underlying CLR threading  
methods

This is based entirely on speculation and “I thought I saw something  
about it once upon a time”  
Is there a page that explains what the threading model of IronRuby is? I  
would be happy to write one up on the wiki, but I have no idea what is  
actually going on.

Thanks, Orion.

---

<div class="post-metadata">

**Author:** ![Orion\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/65b543/32.png) [@Orion\_E](https://www.ruby-forum.com/u/Orion_E)\
**Post date:** [February 15, 2010, 4:00am UTC](https://www.ruby-forum.com/t/threading-model/183460/3 "2010-02-15T04:00:09Z")

</div>

On Mon, Feb 15, 2010 at 11:17 AM, Jimmy S. \<  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

> IronRuby maps Rubyâ€™s green threads directly to CLR threads, and there is no  
> GIL.

Holy race conditions, batman! I’ll be a lot more careful calling  
Thread.new  
now 🙂
