• Post Reply Bookmark Topic Watch Topic
  • New Topic

event dispatching thread

 
luri ron
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what whould happen if i painted the gui not using the event dispatching thread? for example, textArea.setText ("asdfsad") is called in a user thread but not using SwingUtility.invokeLater (..).
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swing is not thread-safe (apart from some small exceptions like JTextArea.append), so the results are unpredictable and your application will probably contain several bugs.
 
luri ron
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks. follow up a design question:
if we need to put every gui update on the event dispatching thread, would this be a performance issue.
for example, if one component in the gui receives 10-20 updates every second and other components are updated through user's actions. in this case, should we seperate these 2 type of updates for better performance?
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How could you separate these? In the end, both need to be executed on the EDT.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!