【发布时间】:2011-11-26 06:28:15
【问题描述】:
我正在我的 windows 机器上用 cygwin 包中的 gcc 编译这个程序
#include<stdio.h>
#include<pthread.h>
void* thread_function(void)
{
printf("hello");
}
int main(int argc,char *argv[])
{
pthread_t thread_id[argc-1];
int i;
int status;
printf("argc is %d ",argc-1);
for(i=0;i<argc-1;i++)
{
pthread_create (&thread_id[i], NULL , &thread_function, NULL);
}
for(i=0;i<argc-1;i++)
pthread_join(thread_id[i],NULL);
}
它编译并创建一个.exe
当我在 cmd 中运行它时
./a.exe 2 3
输出是
argc is 2 hellohello
Question :
pthread.h 和这个线程函数都和linux os 相关,那么为什么它可以在windows 上运行呢?
【问题讨论】:
标签: c windows linux pthreads cygwin