You are using a local thread inside a member function. You must join it or separate it, and since it is local, you must do this in the function itself:
exampleClass::runThreaded() { std::thread processThread(&exampleClass::completeProcess, this);
I assume that you really want to start the data stream and not start the local one. If you do this, you still have to join it somewhere, such as in a destructor. In this case, your method should be
exampleClass::runThreaded() { processThread = std::thread(&exampleClass::completeProcess, this); }
and destructor
exampleClass::~exampleClass() { processThread.join(); }
and processThread should be std::thread , not a pointer to one.
Just a design note: if you have a runThreaded method that acts on a data member of a stream, you must be very careful not to call it more than once before the stream is connected. It may make sense to start the stream in the constructor and join it in the destructor.
source share