Check out example codes for "thread group c++". It will help you in understanding the concepts better.

Code Example 1

std::vector<std::thread> grp;

  // to create threads
  grp.emplace_back(functor); // pass in the argument of std::thread()

  void join_all() {
    for (auto& thread : grp)
      if (thread.joinable())
        thread.join();
  }

Learn ReactJs, React Native from akashmittal.com