我想用线程运行GUI以避免冻结问题,如何添加线程进行查看?或您有任何一般性想法来避免GUI冻结问题。

public class Vark {

    public static void main(String[] args) {
        // Object Creation For the View
        VarkView theView = new VarkView();
        // Object Creation For the Model
        VarkModel theModel = new VarkModel();
        //  Object Creation For the Controller  passing  theModel and theView
        VarkController theController = new VarkController(theView, theModel);
        theView.setVisible(true);
    }
}

最佳答案

为避免冻结,请对长时间运行的任务使用SwingWorker。另请参阅有关Concurrency in Swing

10-07 15:43