I am reading about Ruby Threads (I have never used Ruby before) and I am surprised by the following code:
t1 = Thread.new { print "w"; Thread.pass; print "a"}
t2 = Thread.new { print "e"; Thread.pass; print "l"}
t1.join
t2.join
The book said that it would always show "weakness", and I do not understand why, because if they are real threads (as in other languages), it is not guaranteed that "w" will print before "e".
Thank you for your responses!
source
share