The program shown in Segment 679 does not terminate. Like the sorcerer's apprentice, it has no way to shut down operations.
To arrange for Java to shut down operations, you need to learn about events and listeners.