3 ms·
Ah, thanks. I don't do much Java. So "println() uses synchronized internally" means two println statements will never overlap each other, but still says nothin
by xsmasher 13y ago
Ah, thanks. I don't do much Java.
So "println() uses synchronized internally" means two println statements will never overlap each other, but still says nothing about their interaction with other objects, right? Does nothing to prevent switching threads in the middle of the println and getting two different values?
- ddeck 13y agoCorrect. It synchronizes on the instance of the PrintStream, which has no effect here. The bottom line is that the Point object should have been immutable, which would have made it safe for publication. That requires its fields to be final (among other things), which was not the case.