Question

is

function(Component C){ Box.add(C);validate();}

Thread-safe or does it need to be called in an EventsDispatcherThread?

if they need to be called in the Events Dispatcher Thread, do both Box.add as well as validate() need to be inside the EDT or only box.add is?

Était-ce utile?

La solution

You should run your code in the event dispatch thread.

As you can read in Oracle documentation: http://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html

You can use Swing classes outside EDT only if they are marked as thread safe in the documentation.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top