Why disable the standard output buffer for multithreading?

I am trying to learn multithreading and I have a simple question. In most of the examples that I find, the standard output buffer is disabled before allowing multiple threads to use it with:

setbuf (standard output, NULL);

Why? Codes print the same if I delete this line on them!

+3
source share
2 answers

It is possible that they will not print the same thing - when the output is buffered, it may not be displayed immediately, which may change the order in which the lines are displayed between the streams.

, , .

+4

, , , . I.e., stdout , , stdout.

, .

+2

Source: https://habr.com/ru/post/1775761/


All Articles