To be or not to be.That is a question!

---源于莎士比亚的《哈姆雷特》

导航

ruby 线程学习

i=1
Thread.start{
    while true
        print "Thread 1 \n"
        i+=1
        if i==5 then
            Thread.kill Thread.current
        end
    end
}
j=1
while true
    print "Thread 2 \n"
    j+=1
    if j==4 then
        Thread.exit
    end
end

 

posted on 2013-07-03 14:58  Ijavascript  阅读(181)  评论(0编辑  收藏  举报