求助 linux下创建多线程 为何不能多次创建?
void* pthread_http(void *arg)//发送http请求并libxml解析函数
{
...... //略去定义
while(1)
{
sleep(1);
sem_wait(&empty_sem);
pthread_mutex_lock(&mutex);
ParseRootFile(http,¶m); //该函数中可以发送http请求
in = in % num;
pthread_mutex_unlock(&mutex);
sem_post(&full_sem);
pthread_exit(NULL);
}
}
void* pthread_trans(void *arg) //转码函数
{
.....//略去定义
while(1)
{
sleep(2);
sem_wait(&full_sem);
pthread_mutex_lock(&mutex);
out = out % num;
if ((access(sstr, 0)) == -1)
{ strncat(cmd, xmlparam.srcpath[out], strlen(xmlparam.srcpath[out]));
strncat(cmd, xmlparam.param[out],strlen(xmlparam.param[out]));
strncat(cmd, " &", 2);
system(cmd);
++out;
pthread_mutex_unlock(&mutex);
sem_post(&empty_sem);
pthread_exit(NULL);
}
}
int main()
{
....//略去定义
ini = sem_init(&empty_sem, 0, MAX);
ini2 = sem_init(&full_sem, 0, 0);
if(ini && ini2 != 0)
{
&nb