Swing Worker Thread: Inner Class and Transfer Parameter

I know that SO are specific questions, but I need to advise on what is the best practice in Java for working with a workflow thread.

My application generates large HTML text in response to the calculation process that appears in jTextPane. To avoid blocking the GUI, I used calculations in the Swing Worker Thread.

My task is as follows: to start the calculation, I need a lot of information available in different menus, flags and a list of the graphical user interface, and at the end of the calculation I need to run the functions in EDT.

Here are two options for me:

First you need to send a lot of information to my Swing Worker, and also pass MainFrame to access certain functions in the file "done ()"

public class MyWorker extends SwingWorker<Void, Void> {      

    private MyMainFrame frame;
    public MyWorker(plenty of params) {
    }

    @Override
    public Void doInBackground() {
        //my background process
    }

    @Override
    public void done() {
    frame.myfunc1;
    frame.myfunc2;
    frame.myfunc3;
    }
}

-,

Java. "", .

+3
2

. , -. , (, , ).

, . , done() .

+2

, , , - (, MyWorkerContext).

(), //..., SwingWorker, SwingWorker.

+2

All Articles