A Developer Gateway To IT World...
Synchronization in multithreading
Synchronization
- It is a modifier, applicable only for methods and blocks. But not for classes and variables.
- if multiple threads trying to operate simultaneously on the same java object then there may be a chance of data Inconsistency problem.
- To overcome this problem, we will use synchronized keyword.
- If methods or blocks declared as synchronized then at a time only one thread is allowed to execute that method or blocked on the given object.