下面这段代码是一个for循环上的Web服务如何要等到布尔每次循环等待获得布尔值为true
检查代码
for (i=0;i<contactsString.length-1;i++){
Phone phone=new Phone();
phone.phone=contactsString[i];
check=false;
WebService.getInstance().getApi().checkNumber(phone).enqueue(new Callback<MainResponse>() {
@Override
public void onResponse(Call<MainResponse> call, Response<MainResponse> response) {
availableUsers++;
check=true;
}
@Override
public void onFailure(Call<MainResponse> call, Throwable t) {
}
});
//--- here how to wait untill check is true then continue the loop
}
您在哪里指定代码中的check = true。 –
内onResponse – RealDEV
在地方循环使用递归函数的.....这将很好地工作在这种情况下 – santoXme