Skip to content

Instantly share code, notes, and snippets.

@bbozo
Created November 20, 2013 20:32
Show Gist options
  • Save bbozo/7570484 to your computer and use it in GitHub Desktop.
Save bbozo/7570484 to your computer and use it in GitHub Desktop.
EventMachine with JRuby, running reactor inside a thread doesn't work
require 'eventmachine'
Thread.new{ EM.run }
until EM.reactor_running?; sleep 0.1; end
EM.add_periodic_timer(1){ puts "tick" }
sleep 5
bbozo@uhurajr-ubuntu:~/dev$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
bbozo@uhurajr-ubuntu:~/dev$ ruby em_jruby_problem.rb
tick
tick
tick
tick
bbozo@uhurajr-ubuntu:~/dev$ rvm use jruby
Using /home/bbozo/.rvm/gems/jruby-1.7.4
bbozo@uhurajr-ubuntu:~/dev$ ruby em_jruby_problem.rb
bbozo@uhurajr-ubuntu:~/dev$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment