- synchronized is a modifier applicable for methods and blocks but not for classes and variables.
- If multiple threads are trying to operate simultaneously on the same java object then, there may be a chance of data inconsistency problem.This is called "Race Condition".We can overcome this problem by using synchronized keyword or modifier.
- If a method or block declared as synchronized then at a time only one thread is allowed to execute that method or block on the given objects so that data inconsistency problem won't come.
- But the main disadvantage of "synchronized" modifier is, it increasing waiting time of the threads & creates performance problems.hence if there is no specific requirement then it is not recommended to use synchronized keyword.
- synchronized method compulsory contain implementation whereas abstract method doesn't contain any implementation hence "abstract synchronized" is an illegal combination of methods.
Pages
- Home
- About
- 1.Java - Language Fundamental
- 2.Java - Operator & Assignments
- 3.Java - Flow Control
- 4.Java - Access Modifiers
- 5.Java - OOPs Concept
- 6.Java - Exception Handling
- 7.Java - Multithreading
- 8.Java - Garbage Collection
- 9.Java - java.lang Package
- 10.Java - java.io package
- 11.Java - Collection Framework
- 12.Java - Enum
- 13.Java - Generics
- 14.Java - Assertions
- Java Programming Questions
- Today's Laptops & Mobiles Hot Deals
- Install java(jdk) & Set path & Run program
Flipkart add sale
Java- synchronized modifier / Chapter -7/ Access Modifier
Subscribe to:
Post Comments (Atom)
© Copyright 2017 Javabychetan.blogspot.com |
No comments:
Post a Comment
Be the first to comment!
Don't just read and walk away, Your Feedback Is Always Appreciated. I will try to reply to your queries as soon as time allows.
Note:
1. If your question is unrelated to this article, please use our Facebook Page.
2. Please always make use of your name in the comment box instead of anonymous so that i can respond to you through your name and don't make use of Names such as "Admin" or "ADMIN" if you want your Comment to be published.
Regards,
JavaByChetan
Back To Home