dpdk-gcc 多线程关键字 __thread
来源:互联网 发布:ie js 表格导出excel 编辑:程序博客网 时间:2024/05/16 11:02
__thread 是gcc用于多线程存储局部变量,应该每个线程自己都有一份。
#include <stdio.h>#include <stdlib.h>#include <pthread.h>#include <time.h>__thread int var = 8;void *func0(void *arg){ ++var; printf("func0:%d\n", var);}void *func1(void *arg){ usleep(3); ++var; printf("func1:%d\n", var);}int main(){ pthread_t p0, p1; int i=0; pthread_create(&p0, NULL, func0, NULL); pthread_create(&p1, NULL, func1, NULL); pthread_join(p0, NULL); pthread_join(p1, NULL); return 0;}
result:
func0:9func1:9
代码位置
【1】__thread man
0 0
- dpdk-gcc 多线程关键字 __thread
- gcc __thread关键字
- GCC关键字__thread
- 多线程编程--- __thread关键字
- 多线程编程--- __thread关键字
- 多线程编程--- __thread关键字
- 多线程编程--- __thread关键字
- 多线程编程--- __thread关键字
- 多线程编程--- __thread关键字
- linux多线程编程关键字:__thread,__bulitin_expect
- __thread关键字
- __thread关键字
- __thread关键字
- __thread关键字
- __thread关键字
- __thread关键字
- __thread关键字
- __thread关键字
- 在表空间新增加数据文件和修改表空间数据文件的大小
- Java框架篇---Mybatis 入门
- [Liferay6.2]Liferay Dynamic Query API示例
- Android Studio 的gradle异常问题
- 点击一个按钮,弹出框出现几秒钟之后,跳转到另一个页面
- dpdk-gcc 多线程关键字 __thread
- 实现pc和手机两终端都可以在线播放视频的一种方法
- centos 7中安装virtualBox
- Java中的Semaphore和Lock区别
- react-native的简单使用
- 近期工作总结
- xss 网站攻击
- c++输出当前时间
- 浏览器关闭事件