new(...) public

Creates and runs a new thread to execute the instructions given in block. Any arguments passed to Thread::new are passed into the block.

x = Thread.new { sleep 0.1; print "x"; print "y"; print "z" }
a = Thread.new { print "a"; print "b"; sleep 0.2; print "c" }
x.join # Let the threads finish before
a.join # main thread exits...


Show source
Register or log in to add new notes.