English 中文(简体)
为什么我开始在贾瓦计算时,在吉拉瓦进行冻结。
原标题:Why my GUI in java Freeze when I start calculation in Java

我正在开发一种 j木申请。

but my application Freeze when I start the process of my application

therefore I can update my GUI during the process

do you guys have any idea how to fixed this ?

请将本函及其附件作为大会文件分发为荷。

居伊 我已经尝试这样做,但是它仍然冻结了情报和安全局。

我的法典

final String key = keywords;
        final int dept = dep;
        final double rele = relevance;

        SwingWorker worker = new SwingWorker<Map, Void>() {
            @Override
            public Map doInBackground() {
                final Map resultMap = focusedCrawlingMain.Search(key, dept, rele);  

                return resultMap;
            }

            public void Done(Map dataMap) {
                final List resultList = (List) dataMap.get("relevantList");
                List resultListValue = (List) dataMap.get("relevantListScore");
                int size = resultList.size();

                newData = new String[size][3];
                for(int i = 0; i < size; i++){
                    newData[i][0] = String.valueOf(i+1);
                    newData[i][1] = String.valueOf(resultList.get(i));
                    newData[i][2] = String.valueOf(resultListValue.get(i));
                    model.addRow((new Object[]{newData[i][0],newData[i][1],newData[i][2]}));
                }
            }
        };
        worker.run();
问题回答

http://docs.oracle.com/javase/tutorial/uiswing/concurrency/worker.html

I believe that worker.run() might cause some trouble. If i didn t misunderstand your code you should actually call worker.execute().

Also, move as much of the computations in the Done method to doInBackground, as possible. The Done method executes on the Event Dispatch Thread, which freezes up the GUI, expecially noticable when running long computations.

你们可以单独地进行计算,而不是主要的全球倡议。 http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html 您可以研究一下,其中也涵盖你在多面应用时应当知道的不同情况。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签