Why is there no default java implementation of Del

2019-08-05 06:06发布

I'd like a DelayQueue of scheduled Runnables, where each Runnables should only be run after a certain point in time, specified beforehand. Hence a thread can just keep removing runnables from this queue and process a schedule of events. Why is there no good default implementation of Delayed, that is also Runnable, for this?

The only subinterface of Delayed that seems reasonable is RunnableScheduledFuture, which has a whole bunch of random things that need to be implemented. There has to be an easier way to do this, right?

1条回答
聊天终结者
2楼-- · 2019-08-05 06:41

DelayQueue is more of an infrastructure class that's not used directly by application.

You are probably better off using a ScheduledExecutorService (which internally uses a variant of DelayQueue)

查看更多
登录 后发表回答