While reading Concurrency in practice I read that:
NoVisibility
demonstrated one of the ways that insufficiently synchronized programs can c
It's saying that in main
the intention is to set number=42
and ready=true
at the same time, but since they were called in this particular order there is a race condition with your ReaderThread
where it could (probably will) print out the number even though we really don't want it to.
They would like you to synchronize those 2 variables to be set together.