I want to make something inside a thread that return what he did as string, and I'd like to wait for that string to do other thins. I've been reading about wait()
and notify()
but I dint get it. Can anyone help me?
Here I create the thread that does the operations
new Thread(
new Runnable() {
@Override
public void run() {
synchronized(mensaje) {
try {
mensaje.wait();
mensaje = getFilesFromUrl(value);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
And here where I wait for the string mensaje changes
If the string is not "" then I show a button and some text
synchronized(mensaje) {
if (mensaje.equals("")) {
try {
mensaje.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
btnOk.setVisibility(View.VISIBLE);
lblEstado.setText(mensaje);
}
All this stuff is inside a method