catch 发表于 2014-7-17 10:19:33

大家说下面的运行结果是什么?

本帖最后由 catch 于 2014-7-17 10:27 编辑

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <string.h>

void thread(void)
{
    int i;
    for(i=0; i<3; i++)
      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 pthread error!\n");
      exit (1);
    }
    for(i=0; i<3; i++)
      printf("This is the main process.\n");
    pthread_join(id,NULL);
    return (0);
}
大家说,上面的代码运行结果是什么?希望有详细图解~

页: [1]
查看完整版本: 大家说下面的运行结果是什么?