0

In my project I have a class extending a JFrame. It exposes some methods wich are used by many threads. I am wondering what is the best approach between these two in order to avoid concurrency issues:

public synchronized void doStuff1(final String arg) {
        /*
         * do stuff synchronized...
         */
    }

    public synchronized void doStuff2(final String arg) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                /*
                 * do stuff invoke later...
                 */
            }
        });
    }

Wich one is the most performing?

Svech87
  • 88
  • 1
  • 1
  • 7
  • 1
    http://stackoverflow.com/questions/7196889/swingutilities-invokelater?rq=1 – aviad Oct 22 '16 at 10:48
  • It's not a matter of performance. If your doStuff method is in a different thread than the [Event Dispatch thread](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html), Oracle and I **require** that you use the SwingUtilities invokeLater method. – Gilbert Le Blanc Oct 22 '16 at 10:51

0 Answers0