Multiple Events Dispatcher Themes

I am new to Java Swing and my question is related to Queues and Dispatch threads events.

I read that it is possible to have multiple event queues, each of which contains an AppContext . Likewise, it means that each AppContext event queue has its own event dispatch thread.

+6
source share
2 answers

It is permissible to have one event dispatch thread, as far as I know.

AppContext is apparently not intended to be used by developers , although I am not very familiar with it.

+3
source

1) basically you only needed to know if your code would be executed on EDT (all changes should be made on EDT),

2) if you have any doubts, you can test

if (EventQueue.isDispatchThread()) { 

or (this also returns true if on EDT)

 if (SwingUtilities.isEventDispatchThread()) { 

further here or here

3) all output from background tasks should be enclosed in invokeLater() , the base material on Concurency in Swing

+1
source

Source: https://habr.com/ru/post/896730/


All Articles