1
4
对…的呼唤
|
2
0
你的期望表明你并不真正理解异步的含义。让我们看看下面的算法:
在这里,在发出对operation2的异步调用之前,正在执行operation1。当异步调用operation2时,将创建一个新线程,并且不等待其结束。如果operation3期望operation2已经执行,那么这是代码中的一个错误。如果需要给定线程的结果,则需要与之同步。 |
3
0
试试这个:
试着去尝试睡眠功能(
在每一个平台和操作系统中创建线程都是非常困难的任务,它需要花费很多纳秒,而仅仅输出一些更快速的任务。你甚至可以再加10个
但是
我得到这个代码的输出:
|
rookie · 检查函数模板的所有参数包参数是否属于int 1 年前 |
ivaigult · -W转换和隐式字符串到布尔类型转换 1 年前 |
rainer · 后台插入程序的初始化 1 年前 |
Community wiki · 以理智、安全和高效的方式复制文件 1 年前 |
Shefali Kanaujia · 对C中向量的向量进行排序++ 1 年前 |
Ma Joonyoung · 粗粒度和细粒度链表的时间比较 1 年前 |