A simple multi-threading Java game with monitor pattern -- part5

preview_player
Показать описание

In this version, we move the heavy lifting code from the Event Dispatch thread into the SwingWorker thread, so that the GUI will be more responsive. We also created a JButton to start the SwingWorker thread, and add the GameBoard as an ActionListener.

We re-examined the state variables, categorize them as static final object reference that are not shared among threads (only need to be safely published) and static final object reference that is shared among threads (both safely published and guarded).
Рекомендации по теме
welcome to shbcf.ru