当前位置:网站首页>C+tinycthread implementation thread
C+tinycthread implementation thread
2022-06-11 07:26:00 【Nwafu_ zyccc】
#include <io_utils.h>
#include <tinycthread.h>
int SayHello(char *name) {
PRINTLNF("Run in new thread[%#x]: Hello, %s", thrd_current(), name);
return 1;
}
int main(void) {
thrd_t new_thread;
int result = thrd_create(&new_thread, SayHello, "C lang");
if (result == thrd_success) {
PRINTLNF("Run in Main thread[%#x], created new_thread[%#x]", thrd_current(), new_thread);
} else {
PRINTLNF("Run in Main Thread[%#x], failed to create new_thread", thrd_current());
}
// thrd_sleep(&(struct timespec) {.tv_sec = 0, .tv_nsec = 100000000}, NULL);
int res;
thrd_join(new_thread, &res);
PRINTLNF("Run in Main Thread[%#x], result from thread[%#x]: %d", thrd_current(), new_thread, res);
// thrd_detach(new_thread);
}
边栏推荐
- Shangtang technology has actively resumed work and will vigorously invest in the capacity and deployment of the digital sentry
- 二、用户登录和注册
- [analysis of STL source code] summary notes (3): vector introduction
- Mobile console Gobang (first draft of detailed design)
- MS office level II wrong question record [4]
- [Oracle database] mammy tutorial day04 Sorting Query
- 【CF#693 (Div. 3)】B. Fair Division
- 【CF#262 (Div. 2)】 A. Vasya and Socks
- Interview question 17.08 Circus tower
- CMAP of Matplotlib
猜你喜欢

Installation de SQL Server 2008 (avec mot de passe), création d'une base de données, test de projet de formulaire C

Senior openstacker - Bloomberg, vexxhost upgraded to gold member of openinfra Foundation

2022 low voltage electrician test questions and online simulation test

【LeetCode】-- 17. Letter combination of telephone number

Nodejs database (Part 2)

Directrix of ellipse

Education expert wangzhongze shared his experience for many years: family education is not a vassal

Crmeb/v4.4 Standard Version open version mall source code applet official account h5+app mall source code

big. Js-- use / instance

二、用户登录和注册
随机推荐
[STL source code analysis] summary note (2): overview of containers
Library management system 2- demand analysis
[STL source code analysis] summary notes (9): set/multiset and map/multimap
MS office level II wrong question record [8]
Compound RateModel合约解析
12. integer to Roman numeral
MySQL设置管理员密码无法生效的案例一则
Decimal to binary
JVM学习记录(七)——类加载过程与双亲委派模型
**Count the characters with the largest number of words**
Interview question 02.06 Palindrome linked list
The gap between the parent box and the child box
P1390 sum of common divisors (Mobius inversion)
The maximum number of divisors of numbers in the int range is 1536
[compilation principle] 05- syntax guided semantic computing -- Semantic Computing Based on translation mode
Error occurred in pycharm DeprecatedEnv: Env FrozenLake-v0 not found (valid versions include [‘FrozenLake-v1‘])
pycharm出现error.DeprecatedEnv: Env FrozenLake-v0 not found (valid versions include [‘FrozenLake-v1‘])
@Jsonproperty annotation
mybaits-puls 在xml文件中写sql语句 会报错 Invalid bound statement (not found):
[并发进阶]——线程池总结