可以使用fwrite&安培; FCLOSE从两个线程平行称为为同一个文件描述符? [英] Can fwrite & fclose be called parallely from two threads for the same file descriptor?
本文介绍了可以使用fwrite&安培; FCLOSE从两个线程平行称为为同一个文件描述符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
会发生什么,如果 FWRITE
&安培; FCLOSE
被称为并行地从两个线程对同一文件描述符?
What will happen if fwrite
& fclose
are called in parallel from two threads for the same file descriptor?
推荐答案
FWRITE
和 FCLOSE
的操作文件
数据结构。因为这是不存储不仅仅是文件描述符更多的一个相当大的数据结构,答案是不好的事情。
fwrite
and fclose
operate on the FILE
data structure. Since this is a largish data structure that does store more than just the file descriptor, the answer is bad things.
不这样做,除非你使用保证互斥原子操作。
Don't do this unless you ensure atomic operation using mutexes.
这篇关于可以使用fwrite&安培; FCLOSE从两个线程平行称为为同一个文件描述符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文