I am handling a thread in my application, I am facing a problem with Thread wait function. I created and show my UI using runOnUIThread() , my main thraed was waiting for my UI thread to finish ,after thraed finishes i have do some process in Main thread , here the problem is that Main Process is always in waiting state even my thread finishes it;s job I am using wait and notify() function for this
public String LSVerification() {
String t = null;
t="Sample string";
synchronized(this)
{
AndroidHTMLActivity.this.runOnUiThread(ShowDialog) ;//here i call my thread
try {
this.wait();//here i waiting for my thread to finish it's job
//here i do some process after my thread finish it's job
//the problem is here main process always in wait state
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return t;
}
private Runnable ShowDialog = new Runnable() {
public void run() {
String t = null;
synchronized(ShowDialog)
{
Recognition recg=new Recognition(Activity.this);
recg.show();
this.notify();
}
}
};
try to use Hanlders to update UI after performing a job in background…
Link to Handlers See Code below..