'What is the main difference between the usage of Synchronization (member methods) and the Lock Interface?
For example: I have two member methods (instance methods) inside a class, both marked with the key word "synchronized". If I have thread 1 accessing method 1, can method 2 be accessed by thread 2? If so, what's the difference between using synchronization to the Lock Interface? As far as I understand, Lock Interface allows us to lock in specific parts inside the code, but can it lock in different pieces of code inside a method, and let other parts unlocked, to be used by other threads?I have this image to illustrate the matter: here I'm using the Lock Interface to lock in different pieces of code inside different methods
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
