In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
The content of this article mainly explains "what is the method of C++ multithreading to get the return value", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "C++ multi-threaded method to get the return value is what" it!
Let's use an example to illustrate how to implement this requirement. Calculate the value of (axib) / (xroomy) with multiple threads
There are two ways, respectively
1. Traditional method: sharing pointers between threads
# include#include#include#includeusing namespace std; void func2 (int x, int yjournal intt * ans) {* ans= x int;} int main () {/ / calculate (aplb) / (xmapy) / / with three threads, one thread calculates aquib, the other thread calculates xroomy int a, b, x, y; a = 10, b = 8, x = 2, y = 4; int* sum1 = new int (0); int* sum2 = new int (0) Thread T1 (func2, a, b, sum1); t1.join (); thread T2 (func2, x, y, sum2); t2.join (); 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.