Skip to content

Commit

Permalink
Reverted to old threading
Browse files Browse the repository at this point in the history
  • Loading branch information
DHuckaby committed Mar 19, 2013
1 parent 3a5d49d commit 9b68ff5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions library/src/com/handlerexploit/prime/utils/ImageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import java.net.URLConnection;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
Expand Down Expand Up @@ -111,8 +113,8 @@ public final class ImageManager {

private final Handler mHandler = new Handler(Looper.getMainLooper());

private final ExecutorService mNetworkExecutorService = getCachedFixedThreadPool(Configuration.ASYNC_THREAD_COUNT);
private final ExecutorService mDiskExecutorService = getCachedFixedThreadPool(15);
private final ExecutorService mNetworkExecutorService = newLowPriorityCachedFixedThreadPool(Configuration.ASYNC_THREAD_COUNT);
private final ExecutorService mDiskExecutorService = Executors.newCachedThreadPool();

private final LruCache<String, ReentrantLock> mLockCache = new LruCache<String, ReentrantLock>(100);
private final LruCache<String, Object> mBadUrlCache = new LruCache<String, Object>(20);
Expand Down Expand Up @@ -484,12 +486,12 @@ private File getCacheDirectory(Context context) {
return directory;
}

private ExecutorService getCachedFixedThreadPool(int maximumPoolSize) {
private static ExecutorService newLowPriorityCachedFixedThreadPool(int maximumPoolSize) {
int corePoolSize = 0;
long keepAliveTime = 60L;
TimeUnit unit = TimeUnit.SECONDS;
BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<Runnable>();
LowPriorityThreadFactory factory = new LowPriorityThreadFactory();
ThreadFactory factory = new LowPriorityThreadFactory();
RejectedExecutionHandler handler = new ThreadPoolExecutor.CallerRunsPolicy();

return new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, factory, handler);
Expand Down

0 comments on commit 9b68ff5

Please sign in to comment.