Skip to content

Instantly share code, notes, and snippets.

@BrindleFly
BrindleFly / gist:5492812
Created April 30, 2013 23:57
JRuby thread dump in wait state
"RubyThread-33: my_code.rb:25" daemon prio=10 tid=0x00007fd08c968000 nid=0x8db in Object.wait() [0x00007fd067447000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000e4426ef8> (a org.jruby.ext.thread.Queue)
at java.lang.Object.wait(Object.java:461)
at org.jruby.RubyThread$SleepTask.run(RubyThread.java:906)
- locked <0x00000000e4426ef8> (a org.jruby.ext.thread.Queue)
at org.jruby.RubyThread.executeBlockingTask(RubyThread.java:922)
at org.jruby.RubyThread.wait_timeout(RubyThread.java:1225)
at org.jruby.ext.thread.Queue.pop(Queue.java:143)
@BrindleFly
BrindleFly / gist:4960211
Last active December 13, 2015 19:08
Java wait/notify/notifyAll for MRI and JRuby
# Old school Java wait/notify
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
# Use Java wait/notify/notifyAll
require "java"
class Object
def wait
create_monitor unless @monitor
require 'rubygems'
require 'bunny'
conn = Bunny.new
conn.start
channel = conn.create_channel
queue = channel.queue("app.work", :durable=>true)
# Create exchange for rpc response and bind to temp queue
conn.exchange("app_rpc_response", :type=>:direct)