# Accessing ruby 1.9 interpreter from other threads

**URL:** <https://www.ruby-forum.com/t/accessing-ruby-1-9-interpreter-from-other-threads/113175>\
**Category:** Ruby\
**Created:** [August 28, 2007, 12:33pm UTC](https://www.ruby-forum.com/t/accessing-ruby-1-9-interpreter-from-other-threads/113175 "2007-08-28T12:33:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelleysislander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f6c823/32.png) [@kelleysislander](https://www.ruby-forum.com/u/kelleysislander)\
**Post date:** [August 28, 2007, 12:33pm UTC](https://www.ruby-forum.com/t/accessing-ruby-1-9-interpreter-from-other-threads/113175/1 "2007-08-28T12:33:53Z")

</div>

Hi,

I seem to recall hearing 1.9 is using native threads now.

If so, does that mean it’s now safe for multiple OS threads  
to call into the 1.9 ruby interpreter, and eval or execute  
ruby code? (I’m assuming some sort of interpreter lock would  
need to be grabbed.)

Thanks,

Bill

---

<div class="post-metadata">

**Author:** ![kelleysislander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f6c823/32.png) [@kelleysislander](https://www.ruby-forum.com/u/kelleysislander)\
**Post date:** [August 29, 2007, 9:20am UTC](https://www.ruby-forum.com/t/accessing-ruby-1-9-interpreter-from-other-threads/113175/2 "2007-08-29T09:20:40Z")

</div>

Hi,

At Tue, 28 Aug 2007 19:33:02 +0900,  
Bill K. wrote in [ruby-talk:266532]:

> I seem to recall hearing 1.9 is using native threads now.
> 
> If so, does that mean it’s now safe for multiple OS threads  
> to call into the 1.9 ruby interpreter, and eval or execute  
> ruby code? (I’m assuming some sort of interpreter lock would  
> need to be grabbed.)

And to bind calling native thread a ruby thread. But still not  
provided now.

---

<div class="post-metadata">

**Author:** ![kelleysislander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f6c823/32.png) [@kelleysislander](https://www.ruby-forum.com/u/kelleysislander)\
**Post date:** [August 29, 2007, 12:16pm UTC](https://www.ruby-forum.com/t/accessing-ruby-1-9-interpreter-from-other-threads/113175/3 "2007-08-29T12:16:58Z")

</div>

Nobuyoshi N. wrote:

> And to bind calling native thread a ruby thread. But still not  
> provided now.

A similar mechanism is used in JRuby to “adopt” incoming Java threads as  
Ruby threads, allowing them to participate in thread events like kill  
and raise. But there’s nothing explicit about it; threads that haven’t  
been adopted are adopted automatically. Can’t this be done  
automatically?

- Charlie

---

<div class="post-metadata">

**Author:** ![kelleysislander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f6c823/32.png) [@kelleysislander](https://www.ruby-forum.com/u/kelleysislander)\
**Post date:** [September 5, 2007, 9:29am UTC](https://www.ruby-forum.com/t/accessing-ruby-1-9-interpreter-from-other-threads/113175/4 "2007-09-05T09:29:33Z")

</div>

Hi,

At Wed, 29 Aug 2007 19:16:00 +0900,  
Charles Oliver N. wrote in [ruby-talk:266657]:

> A similar mechanism is used in JRuby to “adopt” incoming Java threads as  
> Ruby threads, allowing them to participate in thread events like kill  
> and raise. But there’s nothing explicit about it; threads that haven’t  
> been adopted are adopted automatically. Can’t this be done automatically?

Does that “adopt” occur in any call to ruby? Isn’t it  
performance overhead?

---

<div class="post-metadata">

**Author:** ![kelleysislander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f6c823/32.png) [@kelleysislander](https://www.ruby-forum.com/u/kelleysislander)\
**Post date:** [September 5, 2007, 8:44pm UTC](https://www.ruby-forum.com/t/accessing-ruby-1-9-interpreter-from-other-threads/113175/5 "2007-09-05T20:44:58Z")

</div>

Nobuyoshi N. wrote:

> performance overhead?  
> Not really, if the thread hasn’t been adopted it just constructs a new  
> Ruby thread to wrap it and a “thread context” to govern frames, scopes,  
> etc for Ruby execution. That’s a one-time hit that only happens the  
> first time a normal Java thread enters Ruby code. From then on it  
> largely just looks like any other Ruby thread.

- Charlie
