CodeGym /Courses /Java Core /Practice with volatile

Practice with volatile

Java Core
Level 7, Lesson 6
Available

"Hello, Amigo!"

5
Task
Java Core, level 7, lesson 6
Locked
Notes for all
Notes for all
5
Task
Java Core, level 7, lesson 6
Locked
Proposals
Proposals
Comments (5)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Jurij Thmsn Level 29, Flensburg, Germany
27 March 2021
I get the difference between synchronized(just on thread at a time can read/write a variable) and volatile(variable is always changed directly in slow memory, not loaded in Cashe), but I can not really imagine an example for the difference in use. Anyone got a good example?
aijo Level 30, Germany, Germany
13 February 2022
You can declare a variable as volatile, but you cannot use synchronized for variables - only for: - methods (public synchronized void ...) - objects( synchronized (MyObject) {...}) - or classes (synchronized (MyClass.class){...}
Andrei Level 41
7 January 2021
Very nice exercises.
JeRiF94 Level 22, Baku, Azerbaijan
29 May 2019
DONE!
Darko Jakimovski Level 18, Kriva Palanka, Macedonia, The Former Yugoslav Republic of
1 June 2019
Well done buddy