代码如下:
void *threadProcessFunction(void *ptr)
{
printf("enter thread\n");
//do thread thing
//exit thread
printf("exit thread\n");
return NULL;
}void startRequestThread()
{
// Create the thread using POSIX routines.
pthread_attr_t attr;
pthread_t posixThreadID;
int returnVal;
returnVal = pthread_attr_init(&attr);
assert(!returnVal);
returnVal = pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
assert(!returnVal);
int threadError = 0;
threadError = pthread_create(&posixThreadID, &attr, &threadProcessFunction, (void*)value);
returnVal = pthread_attr_destroy(&attr);
assert(!returnVal);
if (threadError != 0)
{
printf("create thread error");
}
}