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 "what are the methods for the use of primary threads in C++". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought slowly and deeply. Let's study and learn what are the methods for the use of primary threads in C++.
1 thread start
In std::thread 11, the startup of a thread is ultimately a construction of the object of the thread.
The categories of thread constructs are as follows:
1.1 Thread function has no parameters and no return value
This class can be said to be the simplest thread to start. The function does not need to pass parameters or return the result of the function execution. After the execution is completed, the thread automatically exits.
It looks like:
Void FunDoingNothing (); std::thread (FunDoingNothing)
When writing code, you need to add a header file to make it easier for the compiler to handle thread objects correctly.
1.2 Thread functions have parameters and no return values
In thread 11, variable parameters are used in the constructor of the thread, which makes it possible to customize the incoming parameters when constructing the Cobb object.
The constructor is defined as follows:
Template explicit thread (fame & f, Args&&...) Args)
In practical use, a thread function can be defined as follows when it has parameters:
Void printMsg (int a, int b) {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.