网站制作首选 新鸿儒,如何申请免费空间,在政务网站建设与管理上的讲话,俄语网站建站1. pthread线程通过调用你提供的某些函数开始。这个“线程函数”应该只有一个void*型参数#xff0c;并返回系统的类型。2. 通过向pthread_create函数传递线程函数的地址和线程函数调用的参数来参加线程。3. 线程可以通过pthread_self获取自己的ID。4. 除非线程的创建者或者线…1. pthread线程通过调用你提供的某些函数开始。这个“线程函数”应该只有一个void*型参数并返回系统的类型。2. 通过向pthread_create函数传递线程函数的地址和线程函数调用的参数来参加线程。3. 线程可以通过pthread_self获取自己的ID。4. 除非线程的创建者或者线程本身将线程ID存于某处否则不可能获得一个线程的ID。5. 分离线程意味着通知系统不再需要此线程允许系统将分配给他的资源回收。6. 线程阻塞条件试图加锁一个已经被锁住的互斥量等待某个条件变量调用singwait等待尚未发生的信号执行无法立即完成的IO操作。7. 线程终止将释放所有系统资源但是必须释放由该线程占有的程序资源。 1 #includepthread.h2 #include errors.h3 4 void *thread_routine(void* arg)5 {6 return arg;7 }8 9 int
10 main(int argc, char* argv[])
11 {
12 pthread_t thread_id;
13 void* thread_result;
14 int status;
15
16 status pthread_create(thread_id, NULL, thread_routine, NULL);
17 if( status ! 0)
18 err_abort(status, pthread_create);
19 status pthread_join(thread_id, thread_result);
20 if( status ! 0)
21 err_abort(status, pthread_join);
22 if( thread_result NULL)
23 return 0;
24 else
25 return 1;
26 } 转载于:https://www.cnblogs.com/licongyu/p/5044545.html