Expert, Help please! MultiThreading in C++
Dear Sir or Madam,
I am trying to create 3 threads running paralelly in an C++ object . It is easy to create in C but it's hard and very confusing in C++ object.
Code:
#include <pthread.h>
#include <unix.h>
class ControlManager
{
public:
void ReadMessage(); // This function need associated as a
//thread
void WriteMessage(); // also a thread
void MainLoop(); // also a thread
void SpawnThreads();
private:
pthread_t thread1, thread2, thread3;
}
void ControlManager::SpawnThreads()
{
pthread_create(thread1, NULL, ReadMessage, NULL);
pthread_create(thread2, NULL, WriteMessage, NULL);
pthread_create(thread3, NULL, MainLoop, NULL);
}
Any experts out here can help or point me a right direction.
I greatly appreciated .