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

  • SEARCH
  • Home
  • 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 9246433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:29:15+00:00 2026-06-18T09:29:15+00:00

This is an interview question, that means this could be done in a short

  • 0

This is an interview question, that means this could be done in a short time.
I thought to ask here because I cannot figure out what to do if I were asked.

“Design and code a task scheduler that can take unsynchronized or synchronized tasks”

Please use your imagination/assumption and share your thoughts and comments.

  • 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-18T09:29:16+00:00Added an answer on June 18, 2026 at 9:29 am

    This question is deliberately vague, it’s suppose to show how good you are at designing and solving problems, what kind of assumptions do you make, how you justify them, etc. There is no single, good answer. It’s a matter of approaching the problem.

    That being said here is my take:

    1. My scheduler can take arbitrary Runnable or Callable<V>, I will implement ScheduledExecutorService because it seems to be a good abstraction for the problem. I am using as many standard classes as I can to make API portable and easy to use.

    2. By unsychronized and synchronized I understand: safe to run concurrently and those that require exclusive lock. I.e. the scheduler is not allowed to run two synchronized tasks at the same time.

    3. The distinction between synchronized and unsychronized tasks will be made using marker interface. Annotation is also fine, but harder to extract at runtime.

    4. I won’t give you the full implementation, but it’ll probably wrap some standard ScheduledExecutorService with an additional synchronization for synchronized tasks. I think ConcurrentMap<Class, Semaphore> would do. Before running tasks marked as synchronized I make sure no other synchronized task of the same time is running. I block and wait or reject (this can be configurable).

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

Sidebar

Related Questions

Yesterday in my interview I was asked this question. (At that time I was
I was asked this interview question so thought I would post it here to
Just finished reading this blog post: http://www.skorks.com/2010/03/an-interview-question-that-prints-out-its-own-source-code-in-ruby/ In it, the author argues the case
I am preparing for my interview and came across this question: Consider that i
Here is an interview question that I saw on some forum. I've been trying
I normally ask this question in a interview for tester. Our software is really
This is an interview test question not homework. The test has been done. Which
I have an interview question that I can't seem to figure out. Given an
I can't figure this interview question. You have an array of integers. You need
I had a short interview where a question is like this: set an integer

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.