//
// Created by gxf on 2019/12/13.
//
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h> int shareInt = 0;
void increase_num(void); int main() {
int ret;
pthread_t thread1, thread2, thread3; ret = pthread_create(&thread1, NULL, increase_num, NULL);
ret = pthread_create(&thread2, NULL, increase_num, NULL);
ret = pthread_create(&thread3, NULL, increase_num, NULL); pthread_join(thread1, NULL);
pthread_join(thread2, NULL);
pthread_join(thread3, NULL); printf("sharedInt:%d\n", shareInt); return 0;
} void increase_num(void) {
long i, tmp;
for (i=0; i <= 100000; i++) {
tmp = shareInt;
tmp = tmp + 1;
shareInt = tmp;
}
}

  

最新文章

  1. StgCreateDocfileOnILockBytes复合文档
  2. csharp: InvokeHelper
  3. poj1062 最短路
  4. IOS 中runtime 不可变数组__NSArray0 和__NSArrayI
  5. [剖析Javascript原理]1.原生数据类型
  6. AUC计算方法总结
  7. Angular2 使用CLI创建新项目
  8. springboot整合mybatis出现的一些问题
  9. jQuery.extend 与 jQuery.fn.extend
  10. 找到多个与名为“Home”的控制器匹配的类型的解决方案
  11. 使用Hibernate Validator来帮你做数据校验
  12. js自定制周期函数
  13. mysql常用查询语句
  14. webservice的 发布
  15. 给trac的ticket添加提交时字段验证
  16. 分析ReentrantLock的实现原理
  17. ruby中的三目操作符和include?操作
  18. 记录一次代码错误,elastic search的INDEX需要使用小写字母
  19. 多线程博文地址 http://www.cnblogs.com/nokiaguy/archive/2008/07/13/1241817.html
  20. lucene&amp;solr学习——solr学习(二) Solr管理索引库

热门文章

  1. EM算法之不同的推导方法和自己的理解
  2. SpringBoot开发
  3. hfile.block.cache.size - hbase调优
  4. 后ARM时代,嵌入式工程师的自我修养
  5. 乐字节Java反射之四:反射相关操作
  6. [转帖]降低 80% 的读写响应延迟!我们测评了 etcd 3.4 新特性(内含读写发展史)
  7. 学习Elasticsearch原理笔记
  8. 剑指offer56:删除链表中重复的结点,排序的链表中,删除重复的结点不保留,返回链表头指针。 例如,链表1-&gt;2-&gt;3-&gt;3-&gt;4-&gt;4-&gt;5 处理后为 1-&gt;2-&gt;5
  9. stal 安装
  10. Asp.net core 学习笔记 2.2 migration to 3.0