Android: Wait() the main thread while a dialog gets input in a separate Thread

后端 未结 3 1808
一整个雨季
一整个雨季 2020-12-21 04:37

I\'m writing an activity in Android where the user modifies an SQL Database. The UI consists of an EditText where the user enters the name, and a Seekbar where the user ente

3条回答
  •  臣服心动
    2020-12-21 05:17

    before invoke wait need get the object lock like this:

     synchronized(Thread.currentThread()) { //added
     try {
                Thread.currentThread().wait();
            } catch (InterruptedException e) {
                Log.e("Attractivometer","Main Thread interrupted while waiting");
                e.printStackTrace();
            }
     }
    

    but why you want to make main thread wait?

提交回复
热议问题