开发者

C++ Multithreading vs Python and the GIL

开发者 https://www.devze.com 2022-12-07 20:53 出处:网络
I have several questions about how multithreading is handled in C++. It is known that in Python, thanks to the GIL, having multiple threads running at the "same time" is not truly correct. O

I have several questions about how multithreading is handled in C++. It is known that in Python, thanks to the GIL, having multiple threads running at the "same time" is not truly correct. Only one thread can execute an action at the time. Is this the case with C++? If I use multithreading in C++ is it really simultaneously multithreaded? Can I have multiple threads really running at the same time?.

T开发者_运维问答he other question is that, if I wrote a function in C++, say it is using multiple threads, and I wrap it to use it in Python, is the execution flow and performance of the function written in C++ affected by the GIL? How is this process handled behind the scenes? Will the threads initiated in the C++ function be affected by the Python GIL?

Also, is there any equivalent in C++ for the multiprocessing library in Python? Or all of this could be handled by the use of threads? Thanks in advance.

Parallelism and simultaneously multithreaded apps in C++ vs Python.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号