/* ================================================================= Thread example: thread creation (with input parameter) ================================================================= */ #include #include #include extern "C" void *worker(void *arg) { int * p; p = (int *) arg; // Convert back to the actual type cout << "Hi, my input parameter is " << * p << endl; return(NULL); /* Thread exits (dies) */ } /* ======================= MAIN ======================= */ int main(int argc, char *argv[]) { pthread_t TID; int param; param = 12345; if ( pthread_create(&TID, NULL, worker, ¶m) != NULL ) { cout << "Cannot create thread" << endl; exit(1); } pthread_join(TID, NULL); }