Basicly this is what I have:
Server::
Server (int port) {
cout << "Initializing server.\n";
(...)
pthread_t newthread;
pthread_create(&newthread, NULL, &Server::_startListening, NULL);
cout << "Exit\n";
pthread_exit(NULL); // <-- Question
}
void* Server::_startListening (void* param) {
cout << "Start listening for clients ...\n";
return 0;
}
Question: If I don't put pthread_exit(NULL); in the code, it will work when I compile it on Linux (Ubuntu) but it won't work on Mac OSX 10.6.2. When I compile and run it on linux it will say Initializing server, Start listening for clients, Exit while on Mac OSX it will say Initializing for server, Exit, Start listening for clients.
The problem seems to occur around the pthread_exit, if I place it above the cout << Exit. That message will never be displayed (how weird is that).
Am I doing something wrong?