Sunday 15 January 2017

What is synchronization in respect to multi-threading in Java?

With respect to multi-threading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one Java thread to modify a shared variable while another thread is imn the process of using or updating it.

      Only methods can be synchronized, classes/ variables/ constructors cannot.

      All methods in a class need not be synch, a class can have both synch and non-synch methods


      If a thread goes to sleep having lock with it then it doesn’t release it while asleep

No comments:

Post a Comment