gangadhars
gangadhars

Reputation: 2728

can I run same thread for multiple times?

I have code like:

while(1) {
     if(request == ACCEPT)
          pthread_create(&t1, NULL, test_thread, NULL);
}

and test_thread code is like

void *test_thread(void * arg)
{
       //never ending function
}

This working fine and didn't get any problem. But my question is there any problem if I run like this?

Upvotes: 1

Views: 1496

Answers (1)

Medinoc
Medinoc

Reputation: 6608

You can create multiple threads with the same thread procedure. The only thing you have to worry about is the shared data (global/static variables, etc.).

Upvotes: 2

Related Questions