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 6720039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:09:51+00:00 2026-05-26T09:09:51+00:00

I have to launch 10 tasks asynchronously at variable times through out the day

  • 0

I have to launch 10 tasks asynchronously at variable times through out the day until a certain hour the next day. The closer I get to the time the next day the more I have to repeat these 10 tasks.

My question, is how should I manage this? What executors should I use? What is the best way to manage the memory?

I thought of using an Executors.newScheduledThreadPool that could start a threadpool process with the 10 tasks at variable times. The problem requires me to launch a new set of tasks even though the previous group of tasks have not finished (so probably trigger a new threadpool each time).

I am also thinking of using sort of process registry to manage the different processes that have been launched. When a process is unused anymore than the registry can stop it.

And each time the tasks are done, I thought of flushing the runnables, and stopping the threadpool. Is that overall a good solution?

The problem that may arise, is to have the memory saturated with threadpools. Maybe put a time limit on the threadpool?

  • 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-05-26T09:09:52+00:00Added an answer on May 26, 2026 at 9:09 am

    I guess, you need one dispatching thread inside plain non-scheduling pool and another pool for workers, something like this:

        ExecutorService ex = Executors.newFixedThreadPool(1);
        final ExecutorService workersPool = Executors.newCachedThreadPool();
    
        ex.submit(new Runnable() {
            public void run() {
                try {
                    do { 
                        // determine if it's time to start workers
                        if (timeToStartWorkers()) {
                            workersPool.submit(new Worker(...));
                            workersPool.submit(new Worker(...));
                            ...
                        }
                        // sleep till next time
                        Thread.sleep(timeTillNextCheck);
                    }
                } catch (InterruptedException e) {
                    // handle exception
                }
            }
        });
    

    No need to recreate thread pools.

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

Sidebar

Related Questions

I have a service responsible for many tasks, one of which is to launch
I have a program which runs a bunch of tasks as root at launch.
For example, launch Paint.NET. Then have a look on its memory usage with Task
I have launch mongodb server: [demas@arch.local.net][~]% mongod --dbpatmongod --dbpath /home/demas/temp/ Mon Apr 19 09:44:18
I have a requirement to launch .dot files (ms word templates) as new documents
I have a page that is supposed to launch the Print Preview page onload.
I have a python script that has to launch a shell command for every
I have an application with a launch page that needs to determine what is
I have wanted to try GAE since launch, but coming from ASP .NET and
I have the following C# code to launch an outlook window. The one think

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.