Thread in C++ in MacOS X

最后都变了- 提交于 2019-12-05 05:44:44

Thanks to pwny and PeterT, I figured out the error.

I just needed to compile with clang++ -std=c++11 minimal.cpp and it worked like a charm. I also needed a t.join() at the end to prevent an execution error to happen.

i'm getting different std::thread behaviour running same app. on xcode or instruments (profiling), on xcode the single thread/multithread ratio is 0.6 and in instruments is 3.7 using a 4 thread array,

how is this possible?

 Xcode run:

st...ok - lap: 4875 ms
st/8...ok - lap: 1205 ms
mt...ok - lap: 8330 ms
st/mt ratio:**0.6**

Instruments run:

st...ok - lap: 2182 ms
st/8...ok - lap: 545 ms
mt...ok - lap: 596 ms
st/mt ratio:**3.7**
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!