Threadã1ã¤
th = Thread.fork do p 33 end th.join
Threadãè¤æ°
count = 3 count.times.map do |i| Thread.fork do p i end end.each(&:join)
Process
pid = fork do p 'Process fork' end exitpid, status = *Process.waitpid2(pid)
Fiber
- Fiber ã¨ã¯Thread ã軽éåãããã®.
f = Fiber.new do p "First" Fiber.yield # Fiber.yield ãå¼ã¶ã¨ã³ã¼ã«å ã«å¦çãæ»ã. ããä¸åº¦Fiber#resumeãå¼ã°ããã¨ã㯠ããããå¦çãç¶ç¶ãã. p "Second" Fiber.yield p "Third" Fiber.yield p "4th" Fiber.yield p "5th" end f.resume f.resume