Skip to content

Instantly share code, notes, and snippets.

@qzio
Created January 4, 2010 11:54
Show Gist options
  • Save qzio/268479 to your computer and use it in GitHub Desktop.
Save qzio/268479 to your computer and use it in GitHub Desktop.
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