Synchronization in Java

Synchronization in Java

                                                                            Synchronization
n 
synchronized is a modifier applicable for methods and blocks but not for classes and variables. if multiple threads try to operate simultaneously on the same Java object then there may be a change of data inconsistency problem this is called a race condition 
we can overcome this problem by using synchronized keywords.
if a method a block is declared as synchronized then at a time only one thread is allowed to execute that method or block on the given objects so that the data inconsistency problem will be resolved.

 The disadvantage of the synchronized keyword-:It increases the waiting time of the thread and creates performance problems. hence if there is no specific requirement then it is not recommended to use the synchronizer keyword.


the synchronized method should compulsorily contain whereas the abstract method does not contain any implementation hence abstract synchronized is an illegal combination of modifiers for methods.

                                                //In Progress//