awt is thread-safe
Huh? You do know that Swing uses the
AWT event dispatch thread (EDT), right?

AWT is equally single-threaded and not thread-safe -
http://en.wikipedia.org/wiki/Event_dispatching_threadSeems like this book had already been outdated when it was printed. Because as far as I know the change in Swing rule was made in 2004.
No, Swing has always been single threaded. The "rule" that changed was around creating components off the EDT before they were realised (ie. before making them visible). It's now recommended to always create components in the EDT.
However, active rendering to an AWT or Swing component is OK. I'd recommend a Canvas, and searching for information on using BufferStrategy.
While painting to the component is OK, I'd recommend building and displaying the window and canvas on the EDT first. You also should probably use setIgnoreRepaint(true) to stop the component trying to respond to paint requests from the EDT.
Hello. Thanks for the reply.
Can you give more specific information on why it's OK to paint ? Doesn't painting mean modifying? Is every painting function thread-safe or what?
I use this method to create the Frame and the JPanel. GameMain contains the code to instantiate and show JFrame.
public static void main(String[] args) {
// Use the event dispatch thread to build the UI for thread-safety.
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new GameMain();
}
});
}