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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -