private synchronized void nextTask() { if (executing) { return; } BaseDBTask task; if ((task = taskQueue.poll()) != null) { executing = true; task.execute(); } }
public synchronized void execute(BaseDBTask task) { task.setExecutorCallback(this); taskQueue.add(task); nextTask(); }