Multithreading Interview Questions
Methods of Lock interface i.e., Lock() and Unlock() can be called in different
methods. It is the main advantage of a lock interface over a synchronized block
because the synchronized block is fully contained in a single method.
Lock interface is more flexible and makes sure that the longest waiting thread
gets a fair chance for execution, unlike the synchronization block.
Dostları ilə paylaş: