首页 > 解决方案 > void* 函数的返回类型应该是什么?

问题描述

我正在使用 <pthread.h> lib 学习一些多线程。我使用的函数的返回值有问题:pthread_create(&threads[i], NULL, bar, (void*)i);

酒吧的定义:

void *bar(void* thread_id) {
    long t_id;
    t_id = (long)thread_id;
    std::cout << "I am a thread and my Thread ID is: " << t_id << std::endl;

    for (int i = 0; i < 7; ++i)
        std::cout << "i: " << i << std::endl;

    pthread_exit(NULL);
}

我应该从酒吧返回什么?

标签: multithreadingfunctiontypesreturnvoid

解决方案


推荐阅读