03-31-2009
3,
0
Join Date: Mar 2009
Last Activity: 6 April 2009, 1:05 AM EDT
Posts: 3
Thanks Given: 0
Thanked 0 Times in 0 Posts
when can we destory thread attributes using pthread_attr_destroy() for detached thrd
Hi All,
I am creating detached threads using pthread_create(). As we know, we need to pass the thread attribute structure as an argument to the pthread_Create() API.
I want to know what is the good time to destroy this thread attributes using pthread_attr_destroy() call. Also, I want to know whether we need to call the API pthread_attr_init(&attr_thread) and pthread_attr_setdetachstate(&attr_thread, PTHREAD_CREATE_DETACHED) every time we are creating a detached thread using pthread_create(&threadId, &attr_thread, (void *)ssp_handleAsynchSoipData, NULL).
Presently in my case I am creating and destroying the attribute structure immediately after the call to pthread_create(). But I am susspecting if this is the cause of the crash I am getting in my program.
Has anybody come across such problem. Please suggest
Thanks