
Synchronization is a technique to have control over threads over a shared resources. If they are not managed properly they would give wrong answer. This is race condition.
Synchronization in java can be achieved using.
1. Extending Thread class.
2. Implementing Runnable interface.
Types:
1. Process synchronization
2. Thread synchronization
Thread Synchronization:
How we achieve synchronization:
1. By Using Synchronized Method
2. By Using Synchronized Block
3. By Using Static Synchronization
Without synchronizing method: