stdout
.a
and b
.A
and B
, using fwrite() to write some contents to a
and b
.Question:
123
, B thread is writing 456
, is it possible that 142536
got output in the stdout?Maybe have a look here: fopen and fwrite to the same file from multiple threads
Better define another thread, which is taking control over the file and implement a queue like structure that other tasks can fill with data.
The file thread will then pop (think FIFO) data from the structure and write it to the file.