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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:38:54+00:00 2026-06-02T21:38:54+00:00

Wherever other questions on SO and other sites ask How do I write concurrent

  • 0

Wherever other questions on SO and other sites ask “How do I write concurrent code?“, the answers always involves pretty vague explanations such as “check for data dependencies” or “interdependencies” inside the code. I’m wondering what these mysterious dependencies actually look like as Java code!?!

  • What’s a concrete example of a section of code that can be easily parallelized because it one part doesn’t have a dependency on another part?
  • What’s a concrete example of a section of code that must be serial because of the existence of these dependencies?
  • How do the existence of these dependencies weigh-in with the decision as to use a thread pool or not?

I guess I’m just not seeing the “forest through the trees” here. Thanks in advance!

  • 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-02T21:38:59+00:00Added an answer on June 2, 2026 at 9:38 pm

    What’s a concrete example of a section of code that can be easily
    parallelized because it one part doesn’t have a dependency on another
    part?

    A concurrent application is build on the execution of tasks. You can identify a task as any discrete unit of work. If you can identify parts of your code that stands out as a discrete unit of work and has explicit task boundaries, you can create Runnables for each task and run it in a separate Thread achieving parallelism. Actually a Runnable represents the Task abstraction.
    An example would be a process that needs to load multiple files for processing. The loading of files is a discrete unit of work and can be done in the background by threads without blocking the code flow

    What’s a concrete example of a section of code that must be serial
    because of the existence of these dependencies?

    If Task 2 depends on the calculation/processing of Task 1 then Task 2 must wait for Task 1 to complete, thereby serializing the sequence.
    An example is to load a file in the background and then search for a key in the file

    How do the existence of these dependencies weigh-in with the decision
    as to use a thread pool or not?

    They don’t. Creating a Thread is an expensive operation and Thread Pools are a construct design in reusing threads so as to avoid the overhead of creating new ones. In the Thread Pool you just pass Tasks as Runnables and the Thread Pool is responsible to assign the Task to a thread or create a new thread if needed. You could also define policies via thread pools etc. But they are a tool for concurrent programs. You are expected to have already identified the tasks to submit to the thread pool for execution.

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

Sidebar

Related Questions

I've seen a few other questions dealing with localization but that doesn't seem to
I recently read the discussion https://stackoverflow.com/questions/62617/whats-the-best-way-to-separate-php-code-and-html I am facing a similar dilemma. Currently working
There are many questions and answers on how to implement a global variable in
I've looked at the other threads with similar questions, but I'm new to git,
I am plannning to use whenever gem which among other things will also run
I have a form created in Windows Forms which is draggable wherever I click.
I've created a object that I'd like to have accessible from wherever the request-object
Whenever I learn a new language/framework, I always make a content management system... I'm
Whenever I use WCF, I always try to make immutable classes that end up
Hey guys, I've got a few quick questions. Here is the site: link text

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.