摘要: int pthread_create(pthread_t *restrict tidp, const pthread_attr_t *restrict attr, void *(*start_rtn)(void), void *restrict arg);Returns: 0 if OK, error number on failure第一个参数为指向线程标识符的指针。第二个参数用来设置线程属性。第三个参数是线程运行函数的起始地址。第四个参数是运行函数的参数。 阅读全文
posted @ 2012-02-17 22:39 greencolor 阅读(159) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include <pthread.h>void thread(void){ int i;for(i=0;i<3;i++){ sleep(1);printf("This is a pthread.\n");}}int main(void){pthread_t id;int i,ret;ret=pthread_create(&id,NULL,(void *) thread,NULL);if(ret!=0){ printf ("Create pt 阅读全文
posted @ 2012-02-17 22:37 greencolor 阅读(149) 评论(1) 推荐(0) 编辑