I was running some code that did a printout in a swingworker. I was not getting printouts so I used SwingUtilities.invokeLater
and now it works. I did not expect this result, how did this happen? I would have thought System.out.println
could run outside of the EDT.
That would have been pretty easy to test (not to say, even typing all the code to test this is less work then posting it here):
import java.awt.EventQueue;
public class HelloWorld {
public static void main( String[] args ) {
System.out.println("Hello world");
System.out.println( EventQueue.isDispatchThread());
}
}
results in
Hello world
false
on the console.
So yes, System.out.println
can be used outside the EDT