Programming Tips - Java: Setup a flag variable to tell a thread to stop
Date: 2015sep17
Language: JavaQ. Java: Setup a flag variable to tell a thread to stop
A. There are two ways: volatile and AtomicBoolean.
If only the parent thread sets the flag then volatile is ok.
Declare like this: