“协程"和“协程"之间的区别和“线程"? [英] Difference between a "coroutine" and a "thread"?

查看:47
本文介绍了“协程"和“协程"之间的区别和“线程"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

协程"和线程"有什么区别?

What are the differences between a "coroutine" and a "thread"?

推荐答案

协程是一种顺序处理形式:在任何给定的时间只有一个正在执行(就像子例程 AKA 过程 AKA 函数——它们只是在每个其他更流畅).

Coroutines are a form of sequential processing: only one is executing at any given time (just like subroutines AKA procedures AKA functions -- they just pass the baton among each other more fluidly).

线程(至少在概念上)是一种并发处理形式:多个线程可以在任何给定时间执行.(传统上,在单 CPU、单核机器上,这种并发性是在操作系统的帮助下模拟的——如今,由于如此多的机器是多 CPU 和/或多核的,线程将事实上的 同时执行,而不仅仅是概念上").

Threads are (at least conceptually) a form of concurrent processing: multiple threads may be executing at any given time. (Traditionally, on single-CPU, single-core machines, that concurrency was simulated with some help from the OS -- nowadays, since so many machines are multi-CPU and/or multi-core, threads will de facto be executing simultaneously, not just "conceptually").

这篇关于“协程"和“协程"之间的区别和“线程"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆