i=1Thread.start{ while true print "Thread 1 \n" i+=1 if i==5 then Thread.kill Thread.current end end}j=1while true print "Thread 2 \n" j+=1 if j==4 then Thread.exit endend
本文共 293 字,大约阅读时间需要 1 分钟。
i=1Thread.start{ while true print "Thread 1 \n" i+=1 if i==5 then Thread.kill Thread.current end end}j=1while true print "Thread 2 \n" j+=1 if j==4 then Thread.exit endend
转载于:https://www.cnblogs.com/wangwenfei/p/ruby_thread.html