Something wrong with splats in my previous commit...backing out until I figure this...
[jruby.git] / samples / mvm.rb
blob7f8be2974e8930537d797420e5f580617d17f082
1 require 'jruby/vm'
3 # create the VMs
4 vm1 = JRuby::VM.spawn(['-e' "load 'samples/mvm_subvm.rb'"])
5 vm2 = JRuby::VM.spawn(['-e' "load 'samples/mvm_subvm.rb'"])
7 # connect them to parent
8 vm1 << JRuby::VM_ID
9 vm2 << JRuby::VM_ID
11 # connect them together
12 vm1 << vm2.id
13 vm2 << vm1.id
15 # start them running
16 vm1 << 1
18 # let them run for a while, reading their progress
19 run = true
20 Thread.new { while run; puts JRuby::VM.get_message; end }
21 sleep 20
23 # shut them down
24 run = false
25 vm1 << 'done'
26 vm2 << 'done'
27 vm1.join
28 vm2.join