1

I am pretty much new to Ruby and I was working on a project to run a multithreaded ruby program implemented using celluloid library.

It seems like when I try to run the program using the command:

ruby program_name.rb

The code don't run properly and it says GIL is stopping it from making use of multiple cores. I understand GIL is a locking mechanism used by ruby interpreter, but I was wondering if there is a way to diable it with a special command to make concurrent program run.

If this is something impossible, is there any other way to execute multithreaded program in ruby / with any online editor/IDE that supports such multithreading in Ruby?

kishoredbn
  • 2,007
  • 4
  • 28
  • 47
  • 1
    Use rubinius or jruby. They don't have the lock. – Sergio Tulentsev Mar 16 '16 at 06:17
  • I wish I could have found one straight forward online source on how to install one of these. Can you help? – kishoredbn Mar 16 '16 at 06:20
  • I use chruby with [ruby-install](https://github.com/postmodern/ruby-install). You just do `ruby-install jruby` and that's it for the installation. – Sergio Tulentsev Mar 16 '16 at 06:21
  • I feel like I'm asking questions like a child but I don't know how to trigger jruby. It says jruby is installed in my system but when I try to run the program using jruby program_name.rb, it says command not found! – kishoredbn Mar 16 '16 at 06:29
  • 1
    See the extremist's answer, he links to RVM which is another popular ruby switching tools. After reading its instructions, you should have no questions left :) – Sergio Tulentsev Mar 16 '16 at 06:34

1 Answers1

1

Use jRuby or Rubinius

I prefer rvm for this. See: http://rvm.io

Then run:

rvm get stable
rvm install jruby 

For jRuby. Change to rbx for Rubinius.

Then you can switch between Ruby engines with:

rvm use <jruby/rbx>

Using Celluloid you ought to try both and compare them often.

digitalextremist
  • 5,952
  • 3
  • 43
  • 62