Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top