因为我们的游戏是多线程的程序,当关闭浏览器时,如果Applet的字母下落线程还在运行可能会引发异常。在JBuilder中右击TypeTrainApplet.html,在弹出的菜单中选择Run using default,JBuilder使用AppletViewer运行TypeTrainApplet。启动游戏后直接关闭窗口,在信息窗格中将报告以下的异常信息:
java.lang.NullPointerException at game.TypeTrainApplet$DropCharThread.draw(TypeTrainApplet.java:290) at game.TypeTrainApplet$DropCharThread.run(TypeTrainApplet.java:258)