The need for a way to execute concurrent tasks within Java has been addressed within JSE by the java.util.concurrent.Executor and in a limited fashion in JEE by the WorkManager specification.
As opposed to conditional flag-centric code, a state machine diagram presents a very clear view of the design, and so provides a good example to students. As opposed to conditional flag-centric code, ...