RetrieveBusStoppage retrieveBusStoppage = new RetrieveBusStoppage();
retrieveBusStoppage.executeOnExecutor(retrieveBusStoppage.THREAD_POOL_EXECUTOR,classes[i], Integer.toString(i));
//retrieveBusStoppage.execute(classes[i], Integer.toString(i)); // Retrieving stoppages of bus one by one
for(int j=0;j<busstoppage.get(i).size();j++) {
if (source.equalsIgnoreCase(busstoppage.get(i).get(j).toString())) {
Toast.makeText(getApplicationContext(),"UP", Toast.LENGTH_LONG).show();
result = "up";
break;
}
if (destination.equalsIgnoreCase(busstoppage.get(i).get(j).toString())) {
Toast.makeText(getApplicationContext(),"DOWN", Toast.LENGTH_LONG).show();
result = "down";
break;
}
}
我希望retrieveBusStoppage完全完成然后执行for循环,因为在retrieveBusStoppage中我从数据库中检索busstoppage的值。但在此,它正在执行for循环而不完成retrieveBusStoppage.execute调用。这就是为什么bustoppage的值显示为零,因为数据库中的值未保存在其中。