1.

What is the synchronization process? Why use it?

Answer»

Synchronization is basically a process in java that enables a SIMPLE strategy for avoiding thread interference and memory consistency errors. This process makes sure that resource will be only used one thread at a time when one thread tries to access a SHARED resource. It can be achieved in three different WAYS as given below: 

  • By the synchronized method
  • By synchronized block
  • By static synchronization

Syntax:  

synchronized (object) { //STATEMENT to be synchronized }


Discussion

No Comment Found