As discussed in #102, assigning ivars in #initialize method does not guarantee their visibility. Following synchronization pattern should be used under JRuby.
require 'jruby'
def synchronize
JRuby.reference0(self).synchronized { yield }
end
def initialize
synchronize do
# body of the constructor ...
end
end
def a_method
synchronize do
# body of a_method ...
end
end