In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to apply python multithreading". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use python multithreading.
First, first define a wrapper class, mainly to ensure the pairing of PyGILState_Ensure and PyGILState_Release, and this class can be used in nesting.
# include class PyThreadStateLock {public: PyThreadStateLock (void) {state = PyGILState_Ensure ();} ~ PyThreadStateLock (void) {PyGILState_Release (state);} private: PyGILState_STATE state;}
Second, in the main thread, handle the
/ / initialize
Py_Initialize ()
/ / initialize thread support
PyEval_InitThreads ()
/ / execute before starting the child thread, in order to release the global lock acquired by PyEval_InitThreads, otherwise the child thread may not be able to acquire the global lock.
PyEval_ReleaseThread (PyThreadState_Get ())
/ / other processing, such as startup child threads, etc.
.
/ / ensure that after all the child thread calls are finished
PyGILState_Ensure ()
Py_Finalize ()
/ / No API of python can be called after that
At this point, I believe you have a deeper understanding of "how to apply python multithreading". You might as well come to the actual operation. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.