Q. What is the purpose of the ‘synchronized’ keyword?

A
To increase execution speed
B
To prevent multiple threads from accessing a method/block simultaneously
C
To create a new thread
D
To define a static variable
Solution:

Synchronized ensures thread safety by allowing only one thread to execute the block or method at a time.

Entri Contact Image

Get Expert Advice for Free: Register for Your Free Consultation Now!