Exam 1z0-816 All QuestionsBrowse all questions from this exam
Question 10

Given:

What is required to make the Foo class thread safe?

    Correct Answer: A

    The given Foo class is already thread-safe because it uses a ReentrantLock to ensure that only one thread can enter the critical section defined by the foo method at a time. The lock is acquired before accessing the shared resource (state) and is properly released in the finally block, ensuring that the lock is released even if an exception is thrown. All necessary precautions for thread safety are already in place.

Discussion
Sa16253748596Option: A

A is true