NodeJS和Go lang的单线程如何比Java的多线程更好? [关闭]

我想比较NodeJS,Go lang和Java。 我搜索并发控制。 结果是Java的并发控制是多线程,NodeJS和Go lang的并发控制是单线程。 所以,我想知道NodeJS和Go lang的单线程比Java的多线程好吗?</ p>

有人可以帮助我吗?

每条评论都可以。</ p>
</ div>

展开原文

原文

I wanna compare NodeJS, Go lang,and Java. I search about concurrency control. The result are the concurrency control of Java is multi thread, the concurrency control of NodeJS and Go lang are single thread. So, I wanna know how are Single thread of NodeJS and Go lang better than multi thread of Java ?

Can anyone help me ? Ty for every comment.

1个回答



NodeJS是单线程的。 它具有事件并发模型,该模型在代码中带来了回调序列。 Java具有真正的多线程模型,其中每个程序线程都映射到OS线程上。 该模型的成本是堆栈切换。 Go也是多线程的,但是它使用用户空间或“绿色线程”,它们通过运行时sheduler映射到一个或多个OS线程。 这样的踏板轻巧,开关成本更低,您可以毫无问题地生成数十万个执行例程。 使用Java模型,您可以更精确地控制OS资源共享。</ p>
</ div>

展开原文

原文

NodeJS is single threaded. It has event concurrency model which bring sequence of callbacks in the code. Java has true multi-threaded model where each program thread mapped on OS thread. The cost of this model is stack switch. Go is multi-threaded also but it uses user-space or 'green threads' which are mapped to one or more OS threads by runtime sheduler. Such treads are light and switch cost is less, you can spawn hundreds of thousands of go routines without any problems. With Java model you have in hand more precise control around OS resource sharing.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐