سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top