Multithreading Interview Questions
5. What’s the difference between class lock and object lock?
Class Lock: In java, each and every class has a unique lock usually referred to as a
class level lock. These locks are achieved using the keyword ‘static synchronized’ and
can be used to make static data thread-safe. It is generally used when one wants to
prevent multiple threads from entering a synchronized block.
Example:
Dostları ilə paylaş: