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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:54:14+00:00 2026-05-31T01:54:14+00:00

I have a multithread layout where there is a manager object and a lot

  • 0

I have a multithread layout where there is a manager object and a lot of workers objects.

I have doubt in which layout is better to use:

1 – The workers run in a loop and ask for a “new job” to the manager
constantly after finished.

or

2 – The manager give new jobs to the workers after they finish each
job.

Are there any recommendations for this?

  • 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-31T01:54:15+00:00Added an answer on May 31, 2026 at 1:54 am

    This is a question I have wrestled with many times. Each time I have chosen for the specific situation I am coding for. You should do the same.

    However, to chose correctly you must study the two approaches carefully.

    Consider a test case.

    You have thousands of files to process.


    1. The workers are in control.

    The manager becomes a queue of all of the files to process. You create a fixed number of worker threads which request the next file from the manager and repeat until the list is exhausted.

    Consequences

    You usually end up having to synchronize access to the queue.

    You can tinker with the number of workers to attain maximal throughput for your hardware architecture.

    Sometimes you can dynamically adjust the number of workers depending on the current load but this can be tricky. If successful you can often achieve an exceptionally optimal solution.


    2. The manager is in control.

    The manager creates a new Callable for every file and adds it to an Executor controlled thread pool.

    Consequences

    Well … just about the same if you think about it. The only difference really is that the executor does the queueing.

    There is less synchronization required (except of course internally in the Executor).

    Dynamically adjusting the number of threads is not trivial but I expect one could subclass the Executor to achieve this.


    In summary

    The two architectures are very nearly the same. A number of threads process a sequence of items in parallel.

    The differences are more in the dynamics and the footprint.

    When the workers are in control, a known number of objects are present at any time. An extensive queue can build up but these would presumably be small objects. Work is done at a fixed and predicable pace. If the work starts to pile up you have to make a special effort to deal with it.

    When the manager is in control there can be an explosion of workers, most of which are just sitting around waiting for the Executor. Essentially, the Executor becomes the manager and the Thread pool holds the workers.

    I personally prefer the workers being in control. Mostly I suppose because given two essentially similar architectures I normally prefer the one with the most predictable footprint. I plan to experiment.

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

Sidebar

Related Questions

I have a multithread server that uses one MSSQL which each client should have
I have posted question: how to use log4j in Multithread using java? . i
Since I have to multithread which I can not eloquently solve in PHP I
I have a main loop, and there are some loops inside it. I want
I have a group of 60 objects, each of which i want to have
I have a multithread linux program which uses epoll(7). The epoll(7) man page says
I a have a multithread application (MIDAS) that makes uses of windows messages to
I'm trying to multithread something and i have my program set up such that
I have a layered application in Java which has a multi thread data access
I have a multithreded application in perl for which I have to rely on

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.