Could someone explain what purpose EventQueue object serves?
问题 Could someone explain what purpose EventQueue object serves in Java Swing? I'm mostly confused about how queuing events is applied. Maybe providing common use of an event queue would be helpful. 回答1: Because Swing is single threaded, it uses the EventQueue to hold instances of Runnable so that they can be dispatched sequentially and in the order posted , whether generated by the system or your program. The sine qua non usage is posting an event via EventQueue.invokeLater() , which ensures