class CallbackDispatcher {

    public void endTasksWithError(@NonNull final Collection<DownloadTask> errorCollection,
                                  @NonNull final Exception realCause) {
        if (errorCollection.size() <= 0) return;

        Util.d(TAG, "endTasksWithError error[" + errorCollection.size() + "] realCause: "
                + realCause);

        final Iterator<DownloadTask> iterator = errorCollection.iterator();
        while (iterator.hasNext()) {
            final DownloadTask task = iterator.next();
            if (!task.isAutoCallbackToUIThread()) {
                task.getListener().taskEnd(task, EndCause.ERROR, realCause);
                iterator.remove();
            }
        }

        uiHandler.post(new Runnable() {
            @Override public void run() {
                for (DownloadTask task : errorCollection) {
                    task.getListener().taskEnd(task, EndCause.ERROR, realCause);
                }
            }
        });
    }

      CallbackDispatcher(@NonNull Handler handler, @NonNull DownloadListener transmit);
    public  CallbackDispatcher();

}