I'm working with a lib strangely designed this code basically has a Task
object withonComplete()
and onfail()
methods, both these methods are void so I cannot use return inside them.
I have tried to use an external variable updated inside the task onComplete()
and onfail()
using
mytask.wait();
return value;
with the intention to wait for the completion of the task and then return value but I get
java.lang.IllegalMonitorStateException: object not locked by thread before wait()
if I try something like
while(!mytask.isComplete(){}
to force the method to wait the completion
app totally freezes
How could I get the value at the completion of the task correctly?