Question: Question: In Java, what does the synchronized keyword do when used with a method? A) It ensures that only one thread can execute the method
Question: In Java, what does the synchronized keyword do when used with a method?
A) It ensures that only one thread can execute the method at a time for a given instance of the class, preventing race conditions.
B) It automatically handles thread communication between methods to avoid deadlock situations.
C) It allows a method to be executed in parallel by multiple threads, enhancing performance through concurrency.
D) It guarantees that the method will be executed by the main thread of the application, ensuring single-threaded execution.
Step by Step Solution
There are 3 Steps involved in it
The detailed answer for the above question is provided below The correct option is A It ensures that only one thread can execute the method at a time ... View full answer
Get step-by-step solutions from verified subject matter experts
