-
-
Save egwspiti/6adaac61230cc2607eb3 to your computer and use it in GitHub Desktop.
This file contains 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
class X | |
attr_accessor :a | |
end | |
x = X.new | |
f = Thread.new do | |
sleep 2 | |
x.a = "boom" | |
end | |
def wait_ready(obj, property, timeout) | |
(0..timeout).each do |i| | |
print '.' | |
break if obj.send(property) | |
sleep 1 | |
end | |
puts | |
end | |
puts "variable a is #{x.a}" | |
wait_ready(x, :a, 10) | |
puts "variable a is #{x.a}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment