3

Please let me know if there is a way to run multi-threads in parallel. What I know till now is that Ruby has a global interpreter lock or global VM lock which blocks threads to run in parallel and implement concurrently. Please let me know some good detailed thread examples to actually understand and verify that threads are working in parallel or concurrently.

Jai Madhav
  • 603
  • 8
  • 17

1 Answers1

1

Not with MRI (only concurrency) but Yes with jRuby.

See this great article, there are plenty others on the subject but this one is pretty recent and provides good advice.

apneadiving
  • 114,565
  • 26
  • 219
  • 213
  • 2
    Rubinius 2.0 has real multi-threading too, but it's still in development. – d11wtq Nov 04 '11 at 11:04
  • And also note: C Extensions can unlock the GIL. So depending on what you want to do, you might already use a library that will get arround the limitation – Marc Seeger Nov 04 '11 at 11:20
  • could another thing to take in consideration be the following? : I 've read somewhere that real multi-threading is limited to the number of cpu cores you are running. Doesn't that mean that if you have a dual core, all you get is 2 parallel threads? – Redoman Oct 29 '12 at 00:33
  • That's a fantastic article - the most lucid introduction to threads I've read. – nonbeing Nov 17 '13 at 17:47