I'm reading Concurrent Programming in Java, and getting confused about the fist example.
After looking through the code. I don't find any possibilities that multi-threads invoke methods or get/update attributes on the same object. Why synchronization is added? Why add synchronization to Applet's start() and stop() methods? Would you help me to clarify this? Thanks.
To be or not to be. It's a question.
posted 8 years ago
The move and draw methods of the particles need to be synchronized because they are working on the same data, and are called from different threads - move from the thread of the particle, draw from the AWT event dispatch thread.
For the other synchronized code, I'm as confused as you are...
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus