0

I want to create a std::thread with member function callReverse and 2 other of class threadedName. It's clear how to do it for function taking no arguments and returning void from this StackOverflow question start thread with member function What is the correct way of doing the same for function taking arguments? Can this be used for functions returning some non-void values?

#include <bits/stdc++.h>
#include <thread>
using namespace std;
class threadedName
{
    // class body
    void callPermute()
    {  // function body 
    }
    void callReverse(char s[])
    {  // function body  
    }
    void callRearrange(char s[])
    { // function body  
    }
};
int main()
{
    threadedName ob;
    // doing something

    thread td1(&threadedName::reverseWords, &ob);
    thread td2(&threadedName::callPermute, &ob);
    thread td3(&threadedName::callRearrange, &ob);

    td3.join();
    td2.join();
    td1.join();

    return 0;
}
Anirudh Mitra
  • 63
  • 1
  • 4

0 Answers0