In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
I would like to share with you what the thread library in Clover 11 is. I believe most people don't know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it together.
I. introduction of thread library
Before Category 11, when it comes to multithreading, it is platform-related, such as windows and linux have their own interfaces, which makes the portability of the code is poor. The most important feature of C++ 11 is the support for threads, so that C++ does not need to rely on third-party libraries when programming in parallel, and introduces the concept of atomic class in atomic operations. To use threads in the standard library, you must include
< thread >Header file.
Features: cross-platform, object-oriented encapsulated classes (each thread is a class object).
The principle of its implementation is that conditional compilation is used when packaging the library, that is to say, its underlying layer still calls the thread API of different platforms.
The function name function thread () constructs a thread object without any thread functions associated with it, that is, no thread thread (fn,args1, args2, …) is started. Construct a thread object and associate the thread function fn,args1,args2, … Gets whether the thread idjionable () thread is still executing for the thread function parameter get_id (), and joinable represents a thread that is executing. Jion () after the function call will block the thread, when the thread ends, the main thread continues to execute detach () immediately after the creation of the thread object call, used to separate the created thread from the thread object, the separated thread into the background thread, the created thread "life and death" has nothing to do with the main thread 1.1. Pay attention to when using
Thread is a concept in the operating system. A thread object can be associated with a thread to control the thread and get the state of the thread.
When a thread object is created, no thread function is provided, and the object does not actually correspond to any thread.
# include int main () {std::thread T1; cout
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.