Created
June 24, 2011 18:57
-
-
Save billdueber/1045423 to your computer and use it in GitHub Desktop.
Log and inability to catch breakjump under jruby 1.6.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
def showBreakProblem &blk | |
threads = 2 | |
consumers = [] | |
threads.times do |i| | |
consumers << Thread.new(i) do |i| | |
Thread.current[:num] = i | |
begin | |
(1..10).each do |i| | |
blk.call(i) | |
end | |
rescue Exception => e | |
print "Got exception #{e.inspect}" | |
end | |
end | |
end | |
consumers.each {|t| t.join} | |
end | |
showBreakProblem do |i| | |
tnum = Thread.current[:num] | |
print "#{tnum}: #{i}\n" | |
break if tnum == 1 and i == 3 | |
sleep 0.1 | |
end | |
# OUTPUT | |
# | |
# 0: 1 | |
# 1: 1 | |
# 0: 2 | |
# 1: 2 | |
# 0: 3 | |
# 1: 3 | |
# Exception in thread "RubyThread-1: t2.rb:1" org.jruby.exceptions.JumpException$BreakJump | |
# 0: 4 | |
# 0: 5 | |
# 0: 6 | |
# 0: 7 | |
# 0: 8 | |
# 0: 9 | |
# 0: 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment