摘要: 要想使用POSIX标准线程API(pthreads),需要连接libpthread.so库到程序中。 1、创建线程 进程中的每个线程都有一个线程号,类型为pthread_t。 用pthread_self函数可以返回当前线程的线程号。 线程号之间的比较可以用函数pthread_equal。 if (!pthread_equal (pthread_self (), other_thread)) pthread_join (other_thread, NULL); 每个线程执行一个线程函数: void * function(void *) 用函数pthr... 阅读全文
posted @ 2010-04-27 00:08 刘超觉先 阅读(1945) 评论(0) 推荐(0) 编辑