Hey, I was just curious if you could make a thread out of a class function...if it is possible, what am i doing wrong?
Code:#ifndef USER_H #define USER_H #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <iostream> using std::cout; class USER { private: int *testPTR; int test; pthread_t thread1; char* msg; int iret1; protected: public: USER(); ~USER(); void* run(void *ptr); void printTest(); void start(); }; #endif USER::USER() { test = 1; testPTR = &test; } USER::~USER() { } void USER::start() { iret1 = pthread_create(&thread1, NULL, run, (void*) testPTR); pthread_join(thread1,NULL); return; } void* USER::run(void *ptr) { cout<<"thread\n"; printTest(); } void USER::printTest() { cout<<"test: "<<test; return; }



LinkBack URL
About LinkBacks


