Run this block in a new thread : Ruby Threads « Threads « Ruby






Run this block in a new thread



t = Thread.new do       # Run this block in a new thread
  File.read("data.txt") # Read a file in the background
end                     # File contents available as thread value

 








Related examples in the same category

1.Basic Ruby Threads in Action
2.Get the value returned from a thread
3.Sleep a thread