3

Hi i'd like to do a task out of the EDT :

new Thread(new Runnable(){

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    fBPC.repaint();
                    System.out.println("toto");
                    if (SwingUtilities.isEventDispatchThread()){
                        System.out.println("titi");
                    }
                }
            }).run();

It display that:

toto

titi

Am i not supposed to get only : "toto" because i created a new Thread ?

If not please explain me how to make things in a thread ou of the EDT.

Thank you for helping.

Reimeus
  • 158,255
  • 15
  • 216
  • 276
The Answer
  • 279
  • 1
  • 4
  • 11
  • [for example Runnable#Thread and invokeLater()](http://stackoverflow.com/a/6060678/714968), more in Oracle tutorial Concurency in Swing. or to use SwingWorker, there are implemented methods in API that notify EDT – mKorbel Jun 01 '13 at 13:43

1 Answers1

3

Use Thread.start() instead of Thread.run().

Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106