Quiz 4

Question on use of synchronized

We'll cover the following...

Question # 1

What is the synchronized keyword?

Java provides a built-in mechanism to provide atomicity called the synchronized block. A synchronized method is a shorthand for a synchronized block that spans an entire method body and whose lock is the object on which the method is being invoked.

A synchronized block consists of a reference to an object that serves as the lock and a block of code that will be guarded by the lock.

Synchronized blocks guarded by the same lock will execute one at a ...