CodeGym /Java Course /Java Multithreading /Practice using volatile

Practice using volatile

Java Multithreading
Level 6 , Lesson 5
Available
Practice using volatile - 1

"Hi, Amigo!"

8
Task
Java Multithreading, level 6, lesson 5
Locked
Improving the mind requires more contemplation than memorization
Put volatile modifiers where necessary.
8
Task
Java Multithreading, level 6, lesson 5
Locked
Diligence is the foundation of all work and the key to prosperity
Put volatile modifiers where necessary.
8
Task
Java Multithreading, level 6, lesson 5
Locked
Those who love work need no entertainment
Put volatile modifiers where necessary.
Comments (5)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
catalin1989 Level 37, Romania
2 February 2024
What I understood from this taska and from reading from the internet, is that the volatile keywords ensures visibility, and it is best used with boolean data type. If you use it with other data types, it ensures only visibility, but it doesn't ensure the fact that your thread has the latest value of the data. For this scenario, you need to use synchronized or the Atomic type.
Alex Buyanov Level 47, Netherlands
31 October 2022
Another set of terrible tasks. Okay, I can look up in solution where exactly I should put the modifier. The main question remains, unanswered, though. Why there? Because CodeGym says so? Please, put a comment inside mentor solutions explaining, why "volatile" should be in some places and should not be in others.
Justin Smith Level 41, Greenfield, USA, United States
30 January 2022
LOL how are these easy?
Jurij Thmsn Level 29, Flensburg, Germany
23 November 2021
rather solved these by try and error than understanding. Whats the lesson? I wish there was more explanation on these tasks. 1: output stays the same, volatile variable is never changed in the code. Without explanation, the only thing I learned is that final variables can't be volatile. Is this the only lesson here?
Nouser Level 36, Germany
1 November 2020
Ha, and I thaught that'll be easy...