How do I prove that javaObjectEDT and javaMethodEDT are indeed being run on EDT?

1 visualización (últimos 30 días)
I'm developing a MATLAB-generated Java Package that is to be used in a Java GUI. I want to be sure that when I interact with Swing components, it's being done on the EDT. However, the documentation for javaObjectEDT and javaMethodEDT is pretty sparse. When I run the following code, it tells me that the current thread is 'main' instead of 'AWT-EventQueue-0' like I expect. Am I using this incorrectly? How do I ensure that Java objects and methods are being run on the EDT?
import java.lang.Thread
javaMethodEDT('getName',Thread.currentThread)

Respuesta aceptada

Mohammad Sami
Mohammad Sami el 8 de Abr. de 2021
Your invocation of Thread.currentThread is executed in the matlab main thread not on EDT.
Do as follows.
t = javaMethodEDT('currentThread','java.lang.Thread');
t.getName
%ans =
%AWT-EventQueue-0
You can read this answer for more details.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by