Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (21 sloc) 477 Bytes
/*
* 程序清单 12-1 以分离状态创建的线程
*/
#include "apue.h"
#include <pthread.h>
int
makethread(void *(*fn)(void *), void *arg)
{
int err;
pthread_t tid;
pthread_attr_t attr;
err = pthread_attr_init(&attr);
if (err != 0)
return err;
err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (err == 0)
err = pthread_create(&tid, &attr, fn, arg);
pthread_attr_destroy(&attr);
return err;
}
/* figure12-1.c ends here */
Something went wrong with that request. Please try again.