1.

What Is Difference Between Lock Interface And Synchronized Keyword?

Answer»

The main differences between a LOCK and a synchronized block are:

  1. Having a timeout TRYING to get access to a synchronized block is not possible. Using Lock.tryLock(LONG timeout, TIMEUNIT timeUnit), it is possible.
  2. The synchronized block must be fully contained within a single method. A Lock can have it's calls to lock() and unlock() in SEPARATE methods.

The main differences between a Lock and a synchronized block are:



Discussion

No Comment Found