Javatpoint Logo

difference between synchronization and non synchronization

By: manika*** On: Mon May 20 08:02:23 EDT 2013     Question Reputation7 Answer Reputation65 Quiz Belt Series Points0  72Blank User
what is the major difference between sycronization and non sycronization explain with example...........
Up4Down

 
There is a difference between static synchronized and non synchronized. If method is non synchronized, it is not safe in multi threading system. When method is synchronized, before the VM starts running that method, it has to acquire a monitor, so only one thread has access to this method at the same time. For an instance method (non static), the lock acquired is the one associated with the object you're calling the method on. Situation is more complicated when synchronized method is marked as static also. In this way, the lock acquired is combined with a class (type) so only one thread has access to any static synchronized method at the same time. Image Created0Down

By: [email protected] On: Wed May 22 07:25:41 EDT 2013 Question Reputation0 Answer Reputation392 Belt Series Points0 392User Image
Are You Satisfied :1Yes1No