Ray's playground

 

Fibers, Threads, and Processes(Chapter 12 of Programming Ruby)

1 twos = Fiber.new do
2   num = 2
3   loop do
4     Fiber.yield(num) unless num % 3 == 0
5     num += 2
6   end
7 end
8 
9 10.times { print twos.resume, " "}

 

posted on 2010-07-05 20:25  Ray Z  阅读(113)  评论(0编辑  收藏  举报

导航