小编Rui*_*Vaz的帖子

通过pthread_create传递整数值

我只是想将一个整数的值传递给一个线程.

我怎样才能做到这一点?

我试过了:

    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)

c pthreads

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

c ×1

pthreads ×1