【发布时间】:2017-10-12 03:13:11
【问题描述】:
编写一个c程序来实现两个线程,一个应该在循环中打印来自Arr1[]的字符
and other
should print numbers from Arr2[] in loop?
Input :
char Arr1[6] = {'a','b','c','d','e','f'};
int Arr2[6] = {1,2,3,4,5,6}
Output :
a1b2c3d4e5f6
a1b2c3d4e5f6
a1b2c3d4e5f6
a1b2c3d4e5f6....
如何在上述程序中进行同步以打印所需的输出?
我尝试过使用线程同步技术,例如我使用过的 mutex,但它没有按照输出要求显示
请帮我找到解决办法
我在互联网上遇到了类似的问题,但这些问题是用 java 或 c++ 实现的,我希望它用 c 实现
【问题讨论】:
-
没有程序。请提供实际的minimal reproducible example。
标签: c multithreading synchronization