Let's say I have these two methods in my class.
def set_val(val)
@val = val
end
def get_val
@val
end
I'll spawn multiple threads to call set_val
with different values. Is it guaranteed that reading from @val
returns the correct value, i.e., not the last assigned value, but a value that was passed to set_val
? Could I get something strange when reading? Is the assignment operation atomic? Is it indivisible irrespective of the number of threads?