Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Date: 2015sep17 Language: Java Q. How should I 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:volatile boolean vbKeepRunning = true;AtomicBoolean abKeepRunning = new AtomicBoolean(true);
Add a commentSign in to add a comment