#include
#include
#include
#include
#include
void *thread_func(void *arg)
{
sleep(2);
printf("thread...........\n");
pthread_exit("thread end...");
}
int main(int argc, char *argv[])
{
pthread_t thread;
int err;
err = pthread_create(&thread, NULL, thread_func, NULL);
if (err != 0)
{
fprintf(stderr, "pthread_create: %s\n", strerror(err));
return -1;
}
void *retval = NULL;
//pthread_join(thread, NULL);
pthread_join(thread, &retval); //等待线程退出,并给线程回收资源
printf("join: %s\n", (char *)retval);
return 0;
}