Question: Question: In Java, what is the impact of marking a method with the synchronized keyword? A) It makes the method execute faster by prioritizing thread

Question: In Java, what is the impact of marking a method with the synchronized keyword?

A) It makes the method execute faster by prioritizing thread execution.
B) It allows only one thread to execute the method at a time, blocking other threads until the method is free.
C) It allows multiple threads to execute the method concurrently, but ensures the same variable is not modified.
D) It disables garbage collection for the objects used within the method during its execution.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed answer for the above question is provided below The correct option is B It allows only one thread to execute the method at a time blockin... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!