当前位置:网站首页>[C language] detailed explanation of threads - multi threads for collaborative operation
[C language] detailed explanation of threads - multi threads for collaborative operation
2022-06-30 17:14:00 【Embedded workplace】
Catalog
1、 problem
Summation problem , A child thread calculation 1 + ... + 499 Value , Another thread calculates 500 + ... + 1000 Value , The sum of the last two is added , Or get 1 + ... + 1000 Value .
2、 problem solving
#include <stdio.h>
#include <pthread.h>
int sum_1 = 0;
int sum_2 = 0;
// Functions executed by threads
void* myFunc_1(void* args)
{
for(int i = 1; i < 500; i++)
{
sum_1 = sum_1 + i;
}
}
// Functions executed by threads
void* myFunc_2(void* args)
{
for(int i = 500; i <= 1000; i++)
边栏推荐
- NielsenIQ迎来零售实验室负责人Dawn E. Norvell,将加速扩张全球零售战略
- List announced - outstanding intellectual property service team in China in 2021
- 编译丨迅为iTOP4412开发板Makefile编译
- Etcd教程 — 第八章 Etcd之Compact、Watch和Lease API
- How to connect the Internet Reading Notes - Summary
- “推广+搞笑剧情”,如何碰撞出爆款的火花?
- 【OpenCV 例程200篇】215. 基于多段线绘制近似椭圆
- nodejs学习笔记二
- Etcd教程 — 第九章 Etcd之实现分布式锁
- More than 20million videos have been played in the business list! Why is the reform of Agricultural Academies urged repeatedly?
猜你喜欢

Construction schedule of intelligent management and control platform in Shanxi Chemical Industry Park

IO stream_ recursion

Observation cloud reached in-depth cooperation with tdengine to optimize enterprise cloud experience

平面相交与平面方程

js 从原型链到继承

leetcode:1042. 不邻接植花【随机填入符合要求的 + 后面不会形成矛盾 + set.pop】

24: Chapter 3: develop pass service: 7: user defined exceptions (to represent errors in the program); Create graceexceptionhandler to handle exceptions globally and uniformly (build JSON data of corre

dart:字符串replace相关的方法

将 EMQX Cloud 数据通过公网桥接到 AWS IoT

编译丨迅为iTOP4412开发板Makefile编译
随机推荐
数据库系统概论习题册
Etcd tutorial - Chapter 8 compact, watch, and lease APIs for etcd
数据分析新动力——国内首款开源一体化实时HTAP数据库石原子StoneDB发布
定时任务删除指定时间的的数据
JS Es5 can also create constants?
Dart: string replace related methods
5G业务正式商用,属于广电的机会在哪?
基于SSM实现毕业设计管理系统
Deep learning - (2) several common loss functions
异常类_日志框架
您工厂的MES再不升级,就要被淘汰啦
【C语言】详解线程 — 线程分离函数 pthread_detach
More dragon lizard self-developed features! Production available Anolis OS 8.6 officially released
[wechat applet] basic use of common components (view/scroll-view/wiper, text/rich-text, button/image)
Implementation of aut, a self-developed transport layer protocol for sound network -- dev for dev column
Redis data structure analysis
JSR303以及常见Validator实现
声网自研传输层协议 AUT 的落地实践丨Dev for Dev 专栏
Cesium-1.72 learning (China national boundary)
addmodule_ allmerge_ ams_ im