문제

I need an ScheduledThreadPoolExecutor that runs Task according there priority. If 2 or more Task a pending for immediate execution the one with the highest priority must be called first.

Actually there is a solution for ThreadPoolExecutor, but not for ScheduledThreadPoolExecutor, cause it provides no constructor with a BlockingQueue argument.

See: Java Executors: how can I set task priority?

도움이 되었습니까?

해결책

If I were you I'll have a single threaded ScheduledThreadPoolExecutor which posts to a ThreadPoolExecutor with a PriorityBlockingQueue. Not the most elegant, but it'll get the job done.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top