multi-thread - C++11 的 thread 库,为什么没有start方法。
大家讲道理
大家讲道理 2017-04-17 14:46:04
0
2
1045

C++11 希望用 thread 库来实现多线程,要启动线程,但thread类为什么没有start方法?
我看网上很多文章都是用join方法来开启线程。join显然是同步的,没达到多线程异步的效果。

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
Ty80

std::thread::join()This function is not used to start a thread. On the contrary, it is used to block the current thread and wait for the corresponding thread to end. std::threadA new thread starts running when the object is constructed.

PHPzhong

join() itself does not start a thread.
Asynchronous access can also be done with async, paired with std::future. However, this does not necessarily guarantee that a new thread will be started - unless std::launch::async is mandatory. It can only guarantee execution during get or wait.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template