Synchronous/Asynchronous:任务的同步异步,以及asynchronous callback异步回调

两个线程执行任务有同步和异步之分,看了Quora上的一些问答有了更深的认识。

When you execute something synchronously, you wait for it to finish before moving on to another task. When you execute something asynchronously, you can move on to another task before it finishes.

Synchronized means "connected", or "dependent" in some way. In other words two synchronous tasks must be aware of one another, and one must execute in some way that is dependent on the other. In most cases that means that one cannot start until the other has completed. Asynchronous means they are totally independent and neither one must consider the other in any way, either in initiation or in execution.

MSDN上如是说:

Asynchronous operations can improve performance, because they do not block the calling thread.

同步任务之间有相互关系,存在“等待结束”的关系;异步任务互相之间不管。
也许在CS中“同步”指的是task1的结束和task2的开始是同步的?

那么join一个线程就是父子线程同步,detach就是异步了。

Asynchronous callback指的就是caller call了callee,并不同步地等待callee返回,而是在callee完成返回时通过callback通知caller。

posted @   jily16  阅读(364)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
点击右上角即可分享
微信分享提示