multithreading - 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);
}
我应该从酒吧返回什么?
解决方案
推荐阅读
- arrays - 使用 bash 在数组中旋转值
- javascript - fetch => response.json() 请求被拒绝
- r - 如何修复 R 中的“未定义列选择”错误?
- css - 更改输入自动完成框的颜色
- javascript - 如何通过 JavaScript document.querySelector 设置输入值
- swift - 如何搜索不认识的孩子
- c# - 使用 File.Exists 检查文件名是否存在 - 总是返回 false
- bash - “bash - apt-get”与此命令中的“apt-get”有何不同?
- django - 检索查询集的相关数据
- plsqldeveloper - 将新列添加到表时需要更改所有相关对象(简而言之)