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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:34:21+00:00 2026-06-05T07:34:21+00:00

I have a pipeline of tasks (each task in the pipeline has different parallelism

  • 0

I have a pipeline of tasks (each task in the pipeline has different parallelism requirements), each task works in a different ExecutorService. Tasks work on packets of data, so if we have 10 datapackets then 10 tasks will be submitted to service1, one task per data packet. Once a task submitted to service1 has actually invoked it may submit a new task to work further on the datapacket to service2, service3 or not.

The following code works fine, i.e.:

  • shutdown() is invoked on service1 after everything has been submitted to service1
  • Then awaitTermination() does not return until all the tasks that were submitted before the shutdown() have actually completed running.
    — shutdown() is then invoked on service2 but because all tasks submitted to service1 have completed, and all tasks are submitted to service2 from tasks on service1 all tasks have been submitted to service2 before shutdown() is called on service2.
    — and so on for service3

    ExecutorService[] services = {
            service1,
            service2,
            service3};
    
    int count = 0;
    for(ExecutorService service: services)
    {   
        service.shutdown();
        service.awaitTermination(1, TimeUnit.HOURS);
    }
    

However I have now added a case whereby service2 can break a datapacket into a smaller packet and submit additional tasks on service2 and the code is now failing. The problem is that shutdown() is called on service2 once all the tasks on service1 have completed, but now we want to submit additional service2 tasks from a task running in service2

My questions:

  1. Does shutdown() rerun after all submitted tasks have finished running, or does it return immediately but just doesn’t stop already submitted tasks from running ? Update:answered below
  2. How do I solve my new problem ?
  • 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-05T07:34:23+00:00Added an answer on June 5, 2026 at 7:34 am

    Matts question looks like it may well work but Im concerned it may cause new issues.

    Ive come up with a solution which works without many code changes for my scenario, although it seems a bit clunky

    Ive introduced a new service (service2a) that runs the same task as service2. When a task in service2 wants to submit a small data packet it submits it to service2a rather than service2 so all sub packets are submitted to service2a before service 2 shutdowns. This works for me as the smaller data packets dont need to be broken down into further subpackets and the subpackets idea only applies to service2(a) not any of the other services.

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

Sidebar

Related Questions

I am using scrapy to crawl different sites, for each site I have an
I have just started putting JSLint into my build pipeline and it has been
I have the following Data Flow task in my SSIS package: alt text http://img228.imageshack.us/img228/358/ssis1.png
I have got a pipeline of tasks which basically is a variation of chain
Have a matrix report now that has Position, Hours and Wages for a location
I keep getting the error message Error: 0xC020901E at Data Flow Task, Lookup ProjectId
My software uses multiple threads to do its work. There is a pipeline that
I have a Powershell script that reads values off of the pipeline: PARAM (
I am having an issue with the asset pipeline, I already have a resource
Lets assume we have fixed amount of calculation work, without blocking, sleeping, i/o-waiting. The

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.