Differences between SwingWorker and Executor

前端 未结 2 587
猫巷女王i
猫巷女王i 2021-02-15 15:25

I am using SwingWorker to execute some heavy load tasks on an application I am making . Although today I got across the Executor class and this example :

Executo         


        
2条回答
  •  礼貌的吻别
    2021-02-15 16:20

    1) SwingWorker is created as bridge betweens Java Essentials Classes and Swing by implements Future, and quite guarantee that outoput from methods process, publish and done will be on EventDispatchThread

    2) you can invoke SwingWorker from Executor, this is most safiest methods how to create multithreading in Swing by implements SwingWorker

    3) notice carefully with number or thread, because Executor doesn't care somehow about SwingWorkers life_cycle

    4) another important notice and here

    5) for listening states from SwingWorker you have to implements PropertyChangeListener

提交回复
热议问题