multithreading - Does my ruby thread code will run in parallel automatically when use jRuby -


i have code

require 'thread' work_q = queue.new (0..50).to_a.each{|x| work_q.push x } workers = (0...4).map   thread.new     begin       while x = work_q.pop(true)         50.times{print [128000+x].pack "u*"}       end     rescue threaderror     end   end end workers.map(&:join) 

i know if run using mri, it's run concurently.

but if run on jruby run concurently , parallel, or concurently

is mandatory write thread code using java on jruby achieve parallel process?

in short, yes, parallel. jruby ships custom thread library written in native java, when put require 'thread' @ top of file, you're using java library, not ruby library.

as long java installation supports parallel threads (and modern ones do), , long operating system supports parallel threads (most mordern ones do), jruby code has potential run in parallel well.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -