'pthread_create is called multiple times while the previous thread with same routine is running
Is there any memory leaked or any other problem in second pthread_create call (e.g: memory allocated for pthread) if I accidentally call to pthread_create twice while the previous thread with same routine is running?
static void* thread_routine(void *data)
{
while (1) {sleep(1)}
return NULL;
}
int main()
{
static pthread_t thread_id;
pthread_create(&thread_id, NULL, thread_routine, NULL);
pthread_create(&thread_id, NULL, thread_routine, NULL);
while (1) {//> never return <//}
return 1;
}
Thanks for your helps/answers.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
