1 Star 0 Fork 0

codeveryday/cedcpp_clion

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
cedpthread.cpp 772 Bytes
一键复制 编辑 原始数据 按行查看 历史
codeveryday 提交于 2024-11-21 22:48 +08:00 . m
//
// Created by lmy on 2024-11-19.
//
#include "cedpthread.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#define NUM_THREADS 5
void *PrintHello(void *threadid) {
long tid;
tid = (long) threadid;
printf("Hello World! It's me, thread #%ld!\n", tid);
pthread_exit(NULL);
}
int main(int argc, char *argv[]) {
pthread_t threads[NUM_THREADS];
int rc;
long t;
for (t = 0; t < NUM_THREADS; t++) {
printf("In main: creating thread %ld\n", t);
rc = pthread_create(&threads[t], NULL, PrintHello, (void *) t);
if (rc) {
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
}
/* Last thing that main() should do */
pthread_exit(NULL);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/codeveryday/cedcpp_clion.git
git@gitee.com:codeveryday/cedcpp_clion.git
codeveryday
cedcpp_clion
cedcpp_clion
master

搜索帮助