Hi, would you please explain more about the meaning of synchronization?
+8
A:
Synchronization is the way two or more threads can safely access shared resources without overwriting each other's work.
http://java.sun.com/docs/books/tutorial/essential/concurrency/sync.html
Robert Harvey
2010-01-20 07:08:49
Also, take a look at http://en.wikipedia.org/wiki/Synchronization_(computer_science)
Rory
2010-01-20 07:11:17
Sun's tutorial is quite good. However, note that in the tutorial, "Synchronization" is one of the chapters in the "Concurrency" lesson. I suggest starting from the beginning of the lesson: http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html
Eli Acherkan
2010-01-20 07:16:06
The other option is using java.util.concurrent Atomic primitives, which can be used to implement STM, which lowers the cost of synchronization.
Yann Ramin
2010-01-20 07:43:50
A:
You need to use Synchronization if work in multi threaded environment. Local variables inside methods are thread safe. If you are using global variables (including class level variables) you need to synchronize the method.
fastcodejava
2010-01-20 07:13:25