I have implemented an PriorityExecutor based on http://funofprograming.blogspot.co.il/2013/11/priorityexecutorservice-for-java.html and Specify task order execution in Java
However I want to use an ExecutorCompletionService
and hand it the PriorityExecutor
However I get the following execption:
Caused by: java.lang.ClassCastException: java.util.concurrent.ExecutorCompletionService$QueueingFuture cannot be cast to java.lang.Comparable
at java.util.concurrent.PriorityBlockingQueue.siftUpComparable(PriorityBlockingQueue.java:347)
at java.util.concurrent.PriorityBlockingQueue.offer(PriorityBlockingQueue.java:479)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1364)
at java.util.concurrent.ExecutorCompletionService.submit(ExecutorCompletionService.java:188)
at com.ibm.modmt.impl.sommosAlg.meta.PoolStrategy.multiSubmit(PoolStrategy.java:160)
at com.ibm.modmt.impl.sommosAlg.meta.MultiSOMMOSTask.multiSubmit(MultiSOMMOSTask.java:157)
at com.ibm.modmt.impl.sommosAlg.meta.MultiSOMMOSTask.call(MultiSOMMOSTask.java:85)
at com.ibm.modmt.impl.sommosAlg.meta.MultiSOMMOSTask.call(MultiSOMMOSTask.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
... 1 more
seems that the completion service creates its own Future (a QueueFuture
) out of my Comaprable Future.
Anyone implemented PriorityExecutor with ExecutorCompletionService? Do I need to extend ExecutorCompletionService if so how?
I don't see any way to do it with the builtin impl. However, ExecutorCompletionService is fairly simple code and is GPL, so you could copy it for your own use and modify it to handle your custom Future.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.