I can't be sure about this, obviously, just saying my guess:
Theoritically, printf(3)
uses the system call write(2)
to stdout
, which is a I/O procedure, thus is slower than rest parts of your code which are CPU calculations. So if you have some other synchronization problem, the time spent for printf()
to execute could possibly by accident "fix" some instances of that problem.
However that's not a proper way to fix synchronization problems, so you have to check your code again to find the race conditions that are being resolved in a wrong way.