|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package com.fongmi.android.tv.utils; |
|
|
|
|
|
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue; |
|
|
|
|
import java.util.concurrent.ArrayBlockingQueue; |
|
|
|
|
import java.util.concurrent.RejectedExecutionHandler; |
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor; |
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
import java.util.concurrent.locks.Condition; |
|
|
|
|
@ -12,8 +13,12 @@ public class PauseExecutor extends ThreadPoolExecutor { |
|
|
|
|
private final Condition condition; |
|
|
|
|
private boolean isPaused; |
|
|
|
|
|
|
|
|
|
public PauseExecutor(int corePoolSize) { |
|
|
|
|
super(corePoolSize, corePoolSize, 0, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>()); |
|
|
|
|
public PauseExecutor(int corePoolSize, int queueCapacity) { |
|
|
|
|
this(corePoolSize, queueCapacity, new ThreadPoolExecutor.AbortPolicy()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public PauseExecutor(int corePoolSize, int queueCapacity, RejectedExecutionHandler handler) { |
|
|
|
|
super(corePoolSize, corePoolSize, 0, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(queueCapacity), handler); |
|
|
|
|
pauseLock = new ReentrantLock(); |
|
|
|
|
condition = pauseLock.newCondition(); |
|
|
|
|
} |
|
|
|
|
@ -49,5 +54,4 @@ public class PauseExecutor extends ThreadPoolExecutor { |
|
|
|
|
pauseLock.unlock(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |