I have designed a class Lets call it AsyncClass which implements AsyncCalllback.
It has two global variables boolean flag
and Object val
.
And the constructor look like this:
AsyncClass()
{
this.flag=false;
this.val=null;
}
and onSuccess()
function is defined as:
public void onSuccess(Object x){
this.flag=true;
this.val=x;
}
Now what I want is this to get a return value from here. So I make a call:
AsyncClass callback=new AsyncClass();
service.getResult(createRequestObject(),callback)
and I have a while loop running which keeps waiting for the flag to turn true.
while(!callback.flag);
However it gets stuck in an infinite loop. Why is this happening??