Android warten auf Thread Ende

Meine Funktion hat, um die Daten gerade nach meinem thread Ende, ich bin mit der wait() Methode nach start() mein thread, aber es funktioniert nicht :

private class getDataThread extends Thread {
    @Override
    public void run() {
        super.run();
        while (true) {
            try {
                //...
                Thread.sleep(100);
            } catch (InterruptedException e) {
                //...
            }
        }
    }
}

public void getSensorValues(Bundle bundle) {
    //...
    getDataThread gdt = new getDataThread();
    gdt.start();
    try {
        gdt.wait();
    } catch (InterruptedException e) {
        //...
    }
}

in LogCat :

: An exception occurred during execution !
: Exception caught: java.lang.reflect.InvocationTargetException
: Exception cause: (SYSTEM) java.lang.IllegalMonitorStateException: object not locked by thread before wait() in getSensorValues
: status::FAILURE - output:: Possible errors: (SYSTEM) java.lang.IllegalMonitorStateException: object not locked by thread before wait() in getSensorValues.

Was ich falsch mache?

InformationsquelleAutor Bibix | 2012-07-13
Schreibe einen Kommentar