src/main/java/me/codeboy/common/base/task/CBTaskController.java
private void setAndStartTask(ICBTask task){
        task.setTaskListener(new CBTaskListener() {
            @Override
            public void onTaskStart() {
                lock.lock();
                if (currentExecuteTaskNumber > maxTaskNumber) {
                    try {
                        condition.await();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                currentExecuteTaskNumber++;
                lock.unlock();
            }

            @Override
            public void onTaskEnd() {
                lock.lock();
                currentExecuteTaskNumber--;
                condition.signal();
                lock.unlock();
            }
        });

        task.startTask();
    }
private void setAndStartTask(ICBTask task){
        task.setTaskListener(new CBTaskListener() {
            @Override
            public void onTaskStart() {
                lock.lock();
                if (currentExecuteTaskNumber > maxTaskNumber) {
                    try {
                        condition.await();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                currentExecuteTaskNumber++;
                lock.unlock();
            }

            @Override
            public void onTaskEnd() {
                lock.lock();
                currentExecuteTaskNumber--;
                condition.signal();
                lock.unlock();
            }
        });

        task.startTask();
    }
设置任务的监听器并开始任务
@param task 任务