quiz

Full-stack dev quiz question #52

Full-stack dev quiz question #52quiz

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.

  1. when a class is instantiated by multiple threads
  2. when an object field is modified by multiple threads
  3. when a method is executed by multiple threads
  4. when a static method is executed by multiple threads
  5. when a static final field is read by multiple threads

For the correct answer scroll down

.

.

 

 

 

 

 

 

 

 

 

 

Do not miss valuable content. You will receive a monthly summary email. You can unsubscribe anytime.

 

 

 

 

 

 

 

 

 

 

 

 

 

.

.

.

The correct answer is: b. If you would like to read more, check Is i++ atomic in Java? article.

  1. when a class is instantiated by multiple threads - incorrect, multiple threads create separate objects of the same class
  2. when an object field is modified by multiple threads - correct, the same object is modified by many threads
  3. when a method is executed by multiple threads - incorrect, it is not an issue until the method does not modify the same object
  4. when a static method is executed by multiple threads - incorrect, it is not an issue until the method does not modify the same object
  5. when a static final field is read by multiple threads - incorrect, it is read only operation that does not cause any modifications
If you like what I do, consider buying me a coffee :)

Buy me a coffeeBuy me a coffee