I\'m trying to learn the basics of parallel computing, but I\'m running into an issue on my computer. Take a look at my code below. Basically, I want to print out the line &
Sorry, your professor's mistaken. You need to leverage mutual exclusion or some other barriers in order to guarantee uninterrupted use of a shared resource (which in this case is the STDOUT output file).
Mixed output is potential expected behavior regardless of printf or std::cout::operator<<(). The differences in behavior you see are subtle differences in the execution duration of each, due to their differing design. You should expect this behavior in either case.
I just don't understand why it would be working for everyone else.
It's not. Be a hero to your class and explain how it works and how to fix it. Tell them SO sends their love. :)