Przemys?aw Jakubczyk
Polidea Sp. z o.o.
Copyright (c) 2012
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the follo...
If you think the Android project AndroidImageCache listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package pl.polidea.utils;
//www.java2s.comimport java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @author Przemys?aw Jakubczyk <przemyslaw.jakubczyk@pl.polidea.pl>
*/publicclass StackPoolExecutor extends ThreadPoolExecutor {
public StackPoolExecutor(int poolSize) {
super(
poolSize,
poolSize,
10L,
TimeUnit.SECONDS,
new StackBlockingDeque(),
new LowPriorityThreadFactory()
);
}
public StackPoolExecutor(int poolSize, int maximumPoolSize) {
super(poolSize, maximumPoolSize, 10L, TimeUnit.SECONDS, new StackBlockingDeque(maximumPoolSize), new LowPriorityThreadFactory(), new DiscardPolicy());
}
/**
* @author Przemys?aw Jakubczyk <przemyslaw.jakubczyk@pl.polidea.pl>
*/publicstaticclass LowPriorityThreadFactory implements ThreadFactory {
@Override
public Thread newThread(Runnable runnable) {
final Thread thread = new Thread(runnable, "Image downloading thread");
thread.setPriority(Thread.MIN_PRIORITY);
return thread;
}
}
}