首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

c语言多线程实现并行服务器遇到点小疑点,求解

2012-03-13 
c语言多线程实现并行服务器遇到点小问题,求解!请先看下我的部分代码:int new_fdint ipthread_t id[20]w

c语言多线程实现并行服务器遇到点小问题,求解!
请先看下我的部分代码:

int new_fd;
int i;
pthread_t id[20];  
while(1)
{
  new_fd = accept(new_fd,...,...); //此处省略
  
  pthread_create(id[i++],NULL,(void *)func,NULL); //问题就出在这里,我执行的时候无法创建线程,提示了段错误,我在想是不是这个 id[i++] 这句出现了问题,想问问为什么呢?
}

[解决办法]
&id[i++]
传地址
[解决办法]
&id[i++]
传地址
[解决办法]
int pthread_create(pthread_t*restrict tidp,const pthread_attr_t *restrict_attr,void*(*start_rtn)(void*),void *restrict arg);
-----------------------------------------------------------
The first argument is a pointer
[解决办法]
....
检查有没有越界。。。
i有没有初始化

热点排行