final List<ODocument> asynchResultOne = new ArrayList<ODocument>();
final List<ODocument> asynchResultTwo = new ArrayList<ODocument>();
final AtomicBoolean endOneCalled = new AtomicBoolean();
final AtomicBoolean endTwoCalled = new AtomicBoolean();
database.command(new OSQLAsynchQuery<ODocument>(sqlOne, new OCommandResultListener() {
@Override
public boolean result(Object iRecord) {
asynchResultOne.add((ODocument) iRecord);
return asynchResultOne.size() < synchResultOne.size() / 2;
}
@Override
public void end() {
endOneCalled.set(true);
database.command(new OSQLAsynchQuery<ODocument>(sqlTwo, new OCommandResultListener() {
@Override
public boolean result(Object iRecord) {
asynchResultTwo.add((ODocument) iRecord);
return true;
}