Here is an example from java concurrency in practice making a class Thread Safe.
I want to understand the following in it -
1) Why is synchronized required on get method ?
Logically it looks like if any time set is called since its synchronized so the
value variable should also be visible to other threads. The latest updated value.
Then why is the get method required to be synchronized ?
Any example where thread safety might break if we dont synchronize get method ?
2) Whats the use of @GuardedBy annotation is it mandatory or optional ?
Is it just a marker thing to tell that its access is inside synchronized method ??