private void onTask(Task task) { MyLog.i(TAG, "Executing task %s", task); task.execute(); synchronized (this) { if (mTaskQueue.size() == 0) { mLockManager.releaseSpecialFlag(LockManager.SPECIAL_FLAG_RUNNING_TASK); } } }
@Override public void run() { for (; ; ) { Task task; synchronized (this) { while (mTaskQueue.size() == 0) { try { this.wait(); } catch (InterruptedException x) { MyLog.i(TAG, "Exception in worker thread: %s", x); } } task = mTaskQueue.removeFirst(); } onTask(task); } }