Commit 57fe5d13 authored by lihao's avatar lihao

check data size is over 0

parent 3810529e
package com.mushiny.task; package com.mushiny.task;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
...@@ -56,6 +57,9 @@ public class TaskExecutor<T, U, R> { ...@@ -56,6 +57,9 @@ public class TaskExecutor<T, U, R> {
public boolean execute() { public boolean execute() {
TaskDefinition<T, U, R> t = this.task; TaskDefinition<T, U, R> t = this.task;
Collection<T> data = t.getData(); Collection<T> data = t.getData();
if (null == data || data.isEmpty()) {
return false;
}
countDownLatch = new CountDownLatch(data.size()); countDownLatch = new CountDownLatch(data.size());
AtomicInteger failCount = new AtomicInteger(); AtomicInteger failCount = new AtomicInteger();
data.forEach(d -> pool.execute(() -> { data.forEach(d -> pool.execute(() -> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment