Iam新增了c编程,需要一些帮助。posix pthreads in c
long *taskids[NUM_THREADS];
for(t=0; t<NUM_THREADS; t++)
{
taskids[t] = (long *) malloc(sizeof(long));
*taskids[t] = t;
printf("Creating thread %ld\n", t);
rc = pthread_create(&threads[t], NULL, PrintHello, (void *) taskids[t]);
...
}
此代码片段演示了如何将简单整数传递给每个线程。调用线程为每个线程使用一个唯一的数据结构,确保每个线程的参数在整个程序中保持不变。 Iam不能理解这是怎么发生的,有人可以解释它?
如果您不熟悉C编程,可能会有比pthread更复杂的开始位置。 – WhirlWind 2010-04-13 01:29:45
你从哪里找到这段代码片段? – clahey 2010-04-13 01:33:25
https://computing.llnl.gov/tutorials/pthreads/#PthreadsAPI – Jony 2010-04-13 01:38:01