Green Thread不比Native Thread差

http://zhangyu8374.iteye.com/blog/86299

 

Green Thread 不比Native Thread

在Ruby实现中,Ruby1.8采用的是 Green thread ,JRuby和XRuby采用的是Native thread ,Rubinius既支持 Green thread ,也支持Native thread 。Ruby1.9将由 Green thread 转向Native threadGreen thread 有哪些不足呢?

在“ Ruby Userspace Thread s vs GUI tookits Roundup ”中重点强调了 Green Thread 的一个不足:Blocking syscall将阻塞所有其余的线程,而且这个问题在GUI和网络开发中将随处碰到。另外, Green Thread 不能有效挖掘多核和多CPU的性能。于是大家都把视线转向Native thread 。我对Native thread 不感冒,主要是因为shared state concurrency问题多多。具体有哪些,相信你看完“ The problem with thread s ”就会很清楚了。

现在,Erlang很好的解决了 Green Thread 存在的问题。它没有采用m:1模式,而是采用了m:n模式。Erlang runtime以n个native thread 运行,每个都有一个自己的调度器。而且,Erlang采用shared nothing concurrency,可以把Native Thread 存在的问题都抛之脑后。

看来XRuby的 thread 实现可以好好借鉴一下Erlang的并发范式。在看了“ The Futures of Ruby Thread ing ”之后,更坚定了应该朝这方面努力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值