Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8027329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:46:36+00:00 2026-06-04T23:46:36+00:00

I am working on an API for a scheduler using a backing ScheduledExecutorService. The

  • 0

I am working on an API for a scheduler using a backing ScheduledExecutorService. The basic design, is you register a Provider instance with the Scheduler, and the Scheduler maintains the ScheduledFuture’s for each registered Provider. A Provider is essentially a Runnable that knows how to retrieve firing tasks.

The issue that I am having is what to do when cancelling a scheduled future. The API to cancel a ScheduledFuture takes a boolean parameter allowing the interruption of a Provider which is being fired. I think that it makes sense to alert the Provider when it is being killed along with value of that parameter, so it could do any necessary clean-up.

However, if you alert the Provider instance that it is being killed before just cancelling its ScheduledFuture, there is the possibility that the Provider instance could break the API by blocking until it has completed its execution regardless of the value of that parameter.

On the other side of that, if cancel is called with that value set to true and the ScheduledFuture is cancelled before letting the Provider instance know that it is being killed, it could lose the opportunity to do anything about it.

Note: I cannot use Quartz due to the requirements of the project. Otherwise I would have just used it. Please do not respond telling me to use an alternative framework, as my question is about API design.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:46:37+00:00Added an answer on June 4, 2026 at 11:46 pm

    Technically, isn’t this more of an SPI than an API? I think we can expect more of the implementor as a result, so I would notify them of the closure. As a bit of a hedge, I would also make sure that the notification does nothing by default. If you use a listener, don’t register the provider for this event automatically. If you always call a certain method, provide an abstract base class that does nothing for that call.

    Here is my justification for expecting more of implementers of an SPI:

    If I want to schedule a task I use the ScheduledExecutor API. As an application programmer, I have a use-case that I want to satisfy and I’m trying not to be concerned with the inner workings of how it gets done. As a result, I think APIs should generally be coded very defensively.

    Provider is pretty clearly an SPI. The class name “Provider” is a big hint. It knows exactly how it is to be used and is all about low-level details. I am implementing it specifically because the default implementation doesn’t do what I want. I want the maximum degree of flexibility, even at the expense of more effort on my part. Application programmers should not be expected to write one. They might choose one implementation over another, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on API. We have provided Url of Images. I have to
Does anyone know of any working gvoice api? I have found this project: http://sourceforge.net/projects/gvoicedotnet/
I'm trying to get the google maps for websites API working on my php
Working with Paypal API is the worst experience so far for me as a
I'm working with an api that requires an app to be started, the app
I'm working with LastFM api, let's say I have a class called Artist which
I'm working with wikipedia API and have a problem with the results I'm getting.
I am working with twitter api data and after storing the stream results in
I am working with an API that is returning duplicate Ids. I need to
I'm working with an API that sends me a string of information, separated by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.