Java Event Model

You might think your game has only one thread and you don't have to worry about synchronization, but that's not the case. All graphical apps have at least two threads that can run your code: the main thread and the AWT event dispatch thread. The main thread is (surprise!) the main thread of your program. It starts execution with the main() method of your main class. The AWT event dispatch thread handles user-input events: mouse clicks, keyboard presses, and other events such as window resizing. We'll talk about these input events later in , "Interactivity and User Interfaces," but for now, just know that these input events can access your code through the AWT event dispatch thread.