4

私はJavaスレッドにまったく精通していません:(。呼び出されると、新しいウィンドウを構築するこのクラスがあります(draw()メソッド)。drawGUI()は最後に処理メソッドを呼び出します(compare()メソッド) 。

基本的に構造は

public static void draw() {
    // draws stuff


    compare();
}

問題は、drawGUI()によって描画されたウィンドウに、処理(compare())が終了するまでいくつかの主要な視覚的アーティファクトがあることです。

draw()の実行が終了した後にcompare()を起動するために実装できる最も簡単な方法は何ですか?ありがとうございました

4

2 に答える 2

3

The simplest way is to just put your draw() code inside an asyncExec() inside your thread at the end

new Thread(new Runnable() {
public void run() {

    //do long running blocking bg stuff here
    Display.getDefault().asyncExec(new Runnable() {
        public void run() {
            draw();
        }   
    }
}).start();
于 2012-07-10T15:25:48.510 に答える
1

Assuming that the reason you're getting the artefacts is that draw() hasn't had a chance to return, you can use a Thread.

final T parent = this;
new Thread(new Runnable() {
    public void run() {
        parent.compare();
    }
}).start();

(Where T is the type of the class that has your compare method).

于 2012-07-10T15:26:51.460 に答える