我只是想将一个整数的值传递给一个线程.
我怎样才能做到这一点?
我试过了:
int i;
pthread_t thread_tid[10];
for(i=0; i<10; i++)
{
pthread_create(&thread_tid[i], NULL, collector, i);
}
Run Code Online (Sandbox Code Playgroud)
线程方法如下所示:
void *collector( void *arg)
{
int a = (int) arg;
...
Run Code Online (Sandbox Code Playgroud)
我收到以下警告:
warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
Run Code Online (Sandbox Code Playgroud)