相关疑难解决方法(0)

SwingUtilities.invokeLater和SwingWorker <Void,Object>之间的区别?

有什么区别:

    //Some code, takes a bit of time to process
    (new SomeJFrame()).setVisible(true);

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            (new SomeJWindow()).start();//Start a new thread
        }
    });
Run Code Online (Sandbox Code Playgroud)

和:

    class doGraphics extends SwingWorker<Void, Object> {

        @Override
        public Void doInBackground() {

           //Some code, takes a bit of time to process
            (new SomeJFrame()).setVisible(true);

            return null;
        }

        @Override
        protected void done() {

            (new SomeJWindow()).start();//Start a new thread

        }
    }
    (new doGraphics()).execute();
Run Code Online (Sandbox Code Playgroud)

哪种方法更好用?

java swing multithreading swingworker invokelater

3
推荐指数
1
解决办法
2295
查看次数

标签 统计

invokelater ×1

java ×1

multithreading ×1

swing ×1

swingworker ×1