【发布时间】:2011-09-21 16:57:44
【问题描述】:
这是一个常见的线程创建代码示例。 pthread_create 使用了很多指针/地址,我想知道为什么会这样。
pthread_t threads[NUM_THREADS];
long t;
for(t=0; t<NUM_THREADS; t++){
rc = pthread_create(&threads[t], NULL, &someMethod, (void *)t);
}
使用“&”来引用变量数组“threads”和“someMethod”(而不是“threads”和“someMethod”)是否有主要优势或区别?还有,为什么't'通常作为空指针而不是't'传递?
【问题讨论】: