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?
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.).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.