Singlethread, Multithread, Synchronous, Asynchronous – How do these combine?

huangapple go评论49阅读模式
英文:

Singlethread, Multithread, Synchronous, Asynchronous - How do these combine?

问题

每一幅关于这个主题的图解和解释似乎都不相互一致。

我用图解表达了我对这些概念组合的理解。有人能确认它是否正确或错误吗?

图解中的执行时间轴从左到右。

英文:

Every illustration and explanation concerning this topic that I came across do not seem to be consistent with each other.

I illustrated my understanding of the combinations of these concepts. Can anyone confirm if its correct or erroneous?

The execution timeline in the illustration goes from left to right.

Singlethread, Multithread, Synchronous, Asynchronous – How do these combine?

答案1

得分: 3

这是一个扩展评论,不是一个答案。

你的图片展示了执行任务的线程。在我看来,这是不必要的。

我认为你所困扰的部分是线程属于抽象层次比任何编程系统中所谓的“async”(即任何语言、库或框架)要低的部分。我可以提供一个弱化的类比:如果“async”系统就像快递服务,那么任务就像需要交付的包裹,而线程就像运送它们的卡车。如果你想了解卡车的工作原理,你不需要了解它所载货物的具体情况。但如果你想了解 FedEx 的运作,那谈论包裹——它们应该去哪里,什么时候应该送达——才是核心问题所在。

注意:我并不是说每个编程系统中具有“async”功能的都是建立在线程的较低层次之上,但至少在某些情况下是如此我不会感到惊讶。

无论如何,我的观点是,如果你试图画出N个线程在M个处理器上调度的图片(其中N > M),那么没有必要在任何地方提到“任务”。这只会让图片变得更复杂。


附言:你提到了“异步”,但你没有提及任何特定的编程语言、库或框架。在我看来,“异步”是一个模糊的概念——远没有“线程”那样明确定义。如果你想了解某种特定编程语言、库或框架的某些具体“async”功能,那么你应该明确提到它的名称。它们并不一定都以相同的方式工作。

英文:

This is an extended comment, not an answer


Your pictures show threads executing tasks. IMO, that is unnecessary.

I think that part of what you are struggling with is the fact that threads belong to a lower layer of abstraction than anything that is called async in any programming system (i.e., in any language or library or framework.) If I may offer a weak analogy; If an async system is like a parcel delivery service, then tasks are like the packages that need to be delivered, and threads are like the trucks that carry them. If you want to understand how a truck works, you don't need to know specifics of the cargo that it carries. But if you want to know how FedEx works, then talking about the packages—where they are supposed to go, when they are supposed to arrive—is the very heart of the matter.

Note: I am not saying that every async feature in every programming system that has one is built on a lower layer of threads, but I would not be surprised if that was true in at least a few cases.

Anyway, my point is, if you are trying to draw a picture that illustrates the scheduling of N threads on M processors (where N > M), then there is no need to mention "task" anywhere. It only complicates the picture.


P.S.; You said, "Asynchronous," but you did not mention any specific programming language or library or framework. IMO, "asynchronous" is a vague idea—not nearly as well defined as "thread." If you want to know more about some specific async feature of some language or library or framework, then you should mention it by name. They don't necessarily all work in the same way.

huangapple
  • 本文由 发表于 2023年2月8日 23:16:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/75387869.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定