Created
January 4, 2010 11:54
-
-
Save qzio/268479 to your computer and use it in GitHub Desktop.
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
class Foo | |
def self.set(params) | |
puts "setting myparams = #{params}" | |
@my_params = params | |
end | |
def self.save_str | |
puts "my_param: '#{@my_params}'" | |
sleep(1) | |
puts "my_param: '#{@my_params}' (still in the same method call)" | |
end | |
end | |
Foo.set 'one' | |
Thread.new{Foo.save_str} | |
Foo.set 'two' | |
sleep(3) # just to keep the script alive while save_str is performed | |
## output when runned. | |
setting myparams = one | |
my_param: 'one' | |
setting myparams = two | |
my_param: 'two' (still in the same method call) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment