- Java: Setup a flag variable to tell a thread to stop
Java: Setup a flag variable to tell a thread to stop
There are two ways: volatile and AtomicBoolean. If only the parent thread sets the flag then volatile is ok. Declare like this:
Copyright © 2008-2023, dave. Code samples on Dave's Brain is licensed under the
Creative Commons Attribution 2.5 License.
other material, including English text has all rights reserved.