When multiple threads may cause a problem in a Java application? Check fifty second question of full-stack dev quiz to verify what you know about thread-safe aspect.
When multiple threads may cause a problem in a Java application?
Choose the best single answer that summarizes the problem.
- when a class is instantiated by multiple threads
- when an object field is modified by multiple threads
- when a method is executed by multiple threads
- when a static method is executed by multiple threads
- when a static final field is read by multiple threads
For the correct answer scroll down
.
.
.
.
.
.
The correct answer is: b. If you would like to read more, check Is i++ atomic in Java? article.
- when a class is instantiated by multiple threads - incorrect, multiple threads create separate objects of the same class
- when an object field is modified by multiple threads - correct, the same object is modified by many threads
- when a method is executed by multiple threads - incorrect, it is not an issue until the method does not modify the same object
- when a static method is executed by multiple threads - incorrect, it is not an issue until the method does not modify the same object
- when a static final field is read by multiple threads - incorrect, it is read only operation that does not cause any modifications