Friday, February 12, 2010

Programmer - how to write pthread_create in the same function?

Programmer Question

Hi



Could someone please help with this? I have the following:



// part_1
if (pthread_create(&threadID, NULL, ThreadMain,
(void *) clientSocket) != 0) {
cerr << "Unable to create thread" << endl;
exit(1);
}

// part_2
void *ThreadMain(void *clientSocket) {

pthread_detach(pthread_self());

...

delete (TCPSocket *) clientSocket;
return NULL;
}


I would to have part_2 in part_1 ( I mean without calling TreadMain() function )



thanks for your replies

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails