I'm trying to make an ThreadPoolExecutor with priority. So I define a
private static ThreadPoolExecutor threadpool = new ThreadPoolExecutor(30, MAXPOOL, MAXPOOL, TimeUnit.SECONDS,
queue, new mThreadFactory());
So the key is the queue reference now. But when I declare :
static PriorityBlockingQueue<mDownloadThread> queue=new PriorityBlockingQueue<mDownloadThread>(MAXPOOL,new DownloadThreadComparator());
The compiler gives an error in the first line: The constructor ThreadPoolExecutor(int, int, int, TimeUnit, PriorityBlockingQueue, FileAccess.mThreadFactory) is undefined with a single quickfix: Change type of 'queue' to BlockingQueue. Can you help me to understand whats the problem?
Thanks
Additional Info:
For comparing the runnables I implementd the following class
class mDownloadThread implements Runnable{
private Runnable mRunnable;
private int priority;
mDownloadThread(Runnable runnable){
mRunnable=runnable;
}
@Override
public void run() {
mRunnable.run();
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
}
The comparator:
class DownloadThreadComparator implements Comparator<mDownloadThread>{
@Override
public int compare(mDownloadThread arg0, mDownloadThread arg1) {
if (arg0==null && arg1==null){
return 0;
} else if (arg0==null){
return -1;
} else if (arg1==null){
return 1;
}
return arg0.getPriority()-arg1.getPriority();
}
}