I\'m trying to illustrate the use and importance of volatile with an example that would really not give a good result if volatile was omitted.
UPDATE My answer is wrong, see answer from irreputable.
It's not thread-safe, since access to there's only one writer thread. Should there be another writer thread, value of count is notcount would be become inconsistent to the number of updates.
Visibility of count value to main thread is ensured by checking stopped volatile inside getCount method. This is what is called piggybacking on synchronization in Concurrency in practice book.