java - execute each SwingWorker class one after another

后端 未结 4 1523
不思量自难忘°
不思量自难忘° 2020-12-21 01:21

I have multiple classes extending the SwingWorker. What I wish to accomplish is to execute each class one after another (without executing the next class in the previous cla

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-21 02:04

    Memory Consistency Properties summarizes the JLS: "Each action in a thread happens-before every action in that thread that comes later in the program's order." Simply re-factor each worker's doInBackground() into a separate method, and call each in sequence:

    @Override
    protected Void doInBackground() throws Exception {
        doCsw1();
        doCsw2();
        doCsw3();
        return null;
    }
    

提交回复
热议问题