在Windows中使用C在两个线程之间共享缓冲区的方法有哪些?(What are the ways to share a buffer between two threads using C in W

编程入门 行业动态 更新时间:2024-10-26 08:22:28
在Windows中使用C在两个线程之间共享缓冲区的方法有哪些?(What are the ways to share a buffer between two threads using C in Windows? [duplicate])

这个问题在这里已有答案:

添加两个数字而不使用运算符 3个答案

想想我使用win32 api的createthread()创建了2个线程的场景。 我正在连接到一个串口的一个线程中继续数据,第二个线程将对线程1的数据执行操作。我将数据存储在一个缓冲区中,但是我想在线程2中使用该缓冲区,这样我就可以使用thraed 2函数继续对数据进行操作了。 所以我如何在两个线程之间共享数据。

This question already has an answer here:

Adding two numbers without using operators 3 answers

think about scenario like i have created 2 threads using createthread() of win32 api. i am getting continues data in one thread which is connected to one serial port and 2nd thread will perform operation on the data of thread 1. i stored the data in one buffer in thraed 1. but i want to use that buffer in thread 2 , so that i can continue my operation on data by using thraed 2 function. so how i can share the data between two threads.

最满意答案

printf函数返回写入的元素数。 在这种情况下,字符数是x (第一个%*c )和y (第二个)之和。

The printf functions returns the number of elements written. In this case is the number of characters which is the sum of x (the first %*c) and y (the second).

更多推荐

本文发布于:2023-08-07 08:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1463683.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓冲区   线程   两个   方法   有哪些

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!