volatile vs synchronized — when to use each?

volatile for single-writer flags (shutdown, initialized) where no read-modify-write. synchronized or java.util.concurrent locks when multiple threads update...

volatile vs synchronized — when to use each? · Home · Support the platform