You probably need to get information about the Java memory model. Multithreading is not just the interleaving of threads; it is about the visibility of actions from one thread to another.
concurrency: , , , () . , volatile
, - ( , ).
finished
- , -, . ,
while (!finished);
if (!finished) while (true);
- , , finished
, , , .
, : " ": , , - , .