Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.concurrent.*;
- import java.util.concurrent.atomic.AtomicInteger;
- public class ExecutorServiceExt extends ThreadPoolExecutor {
- private AtomicInteger count = new AtomicInteger(0);
- public ExecutorServiceExt(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) {
- super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
- }
- @Override
- public void execute(final Runnable command) {
- count.incrementAndGet();
- super.execute(new Runnable() {
- @Override
- public void run() {
- command.run();
- postExecute();
- }
- });
- }
- private void postExecute() {
- if (count.decrementAndGet() == 0) {
- allFinished();
- }
- }
- public void allFinished() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement