An Issue I Wish To Raise Awareness On
Kagamin via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jul 29 03:13:47 PDT 2017
On Tuesday, 25 July 2017 at 19:22:11 UTC, Marco Leise wrote:
> Since I/O is thread-safe[1], it should ideally be `shared`
> the way you put it.
Also it sounds like a bad decision.
void f()
{
printf("hello ");
printf("world\n");
}
If you have shared stdout and this function runs in 2 threads,
you will get a character soup
---
hello hello world
world
---
If you have a separate line buffered stdout for each thread, you
will get whole lines in the output
---
hello world
hello world
---
And incur no locking.
More information about the Digitalmars-d
mailing list