How do I prove that javaObjectEDT and javaMethodEDT are indeed being run on EDT?
1 view (last 30 days)
Show older comments
Charles Yang
on 7 Apr 2021
Commented: Charles Yang
on 8 Apr 2021
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)
0 Comments
Accepted Answer
Mohammad Sami
on 8 Apr 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.
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!