Hi Guys

I am bit new to pthreads.. I have a multi threaded socket program..

The main function looks as follows
-------------------------------------
pthread_attr_t attr,attrsd;
pthread_attr_init(&attr);
pthread_attr_init(&attrsd);

// No need to join the threads
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_attr_setdetachstate(&attrsd, PTHREAD_CREATE_DETACHED);


pthread_t shutdown_check;
pthread_create( &shutdown_check, &attrsd, sync_shutdown_servers ,NULL);
pthread_detach(shutdown_check);

while(1){ // While loop listening to connections are executing the request in a different thread
//*x = 0;
LOG_INFO_MSG("Inside the Lisening Loop");
newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, (socklen_t *) &clilen);

if (newsockfd < 0){
LOG_ERROR_MSG("ERROR on accept");
//goto exit;
}else{

pthread_t thread;

LOG_DEBUG_MSG("Request Accepted on Socket %d\n",newsockfd);

//put it in to the new thard to handle the work
int xx = pthread_create( &thread, &attr, runcomm ,(void *)newsockfd);

LOG_DEBUG_MSG("%d",xx);

//Recover the resource when its done
pthread_detach(thread);
}

}

------------------------------------------------------------------------------------------------------------

On the application I need to run a background thread.. which goes to sleep time to time

pthread_t shutdown_check;
pthread_create( &shutdown_check, &attrsd, sync_shutdown_servers ,NULL);
pthread_detach(shutdown_check);

The method sync_shutdown_servers looks as follows

void sync_shutdown_servers(void *x){

while(1){
LOG_INFO_MSG("Shutdown checker invoked");
sleep(get_shutdown_check_interval());
//do some work
}
}

My problem is when I create this background in the main function before the while loop
Neither of the connections are not accepted.. When I comment the thread creation before the while loop it works..

Is calling sleep() with in the thread method puts main thread to be on sleep as well?

What am I doing wrong here??