Synchronized keyword
=========================================================================================================================
-> Synchronized modifier is applicable only for methods and blocks but not for classes and variables.
-> If multiple threads are operating simultaneously on same java object then there may be a chance of data inconsistency problem.
-> To overcome this problem we should go for synchronized.
-> If a method or block declared as synchronized then at a time only one thread is allowed to operate method or block on the given object.
-> So that we can resolve data inconsistency problem.
-> The main advantage of synchronized keyword is we can overcome data inconsistency problems.
-> But the main disadvantage is it increases waiting time of threads and creates performance problems.
-> Hence if there is no specific requirement then it is never recommanded to use synchronized keyword.
-> Synchronized method should compulsory contain implementation whereas abstract method should not contain implementation.
-> Hence [abstract synchronized] combination is illegal for methods.
=========================================================================================================================
-> Synchronized modifier is applicable only for methods and blocks but not for classes and variables.
-> If multiple threads are operating simultaneously on same java object then there may be a chance of data inconsistency problem.
-> To overcome this problem we should go for synchronized.
-> If a method or block declared as synchronized then at a time only one thread is allowed to operate method or block on the given object.
-> So that we can resolve data inconsistency problem.
-> The main advantage of synchronized keyword is we can overcome data inconsistency problems.
-> But the main disadvantage is it increases waiting time of threads and creates performance problems.
-> Hence if there is no specific requirement then it is never recommanded to use synchronized keyword.
-> Synchronized method should compulsory contain implementation whereas abstract method should not contain implementation.
-> Hence [abstract synchronized] combination is illegal for methods.
Comments
Post a Comment