سؤال

I have a scheduled executor service and I require the Futures returned after tasks are scheduled. The Javadoc says that a ScheduledFuture is returned after scheduling a task - however, how can I obtain subsequent Futures of yet to be run tasks?

My call looks like the following: exec.scheduleAtFixedRate(new Task(), 0, interval, TimeUnit.MINUTES);

New tasks are indeed submitted and run, however I only have a future for the first time that the call is made. Is this Future something that is reused or is reusable?

هل كانت مفيدة؟

المحلول

It is the same Future for all the executions. cancelling it cancels the current and all future executions.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top