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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:08:31+00:00 2026-05-23T16:08:31+00:00

I have data stored in a HashMap, which I want to access via multiple

  • 0

I have data stored in a HashMap, which I want to access via multiple threads simultaneously, to split the work done on the items.

Normally (with a List for example) I would just give each thread an index to start with and could easily split the work like this:

for(int i = startIndex; i < startIndex+batchSize && i < list.size(); i++)
{
    Item a = list.get(i);
    // do stuff with the Item
}

Of course this doesnt work with a HashMap, because I can’t access it via an index.

Is there an easy way to iterate only over a part of the map? Should I rather use another data structure for this case?

I read about SortedMap, but it has too much overhead I dont need (sorting the items). I have a lot of data and performance is crucial.

Any tips would be highly appreciated.

  • 1 1 Answer
  • 2 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-23T16:08:31+00:00Added an answer on May 23, 2026 at 4:08 pm

    If you only do the traversal a few times, or if the map doesn’t change you could get a Set of keys, and then send that to an array. From there its pretty much your normal method. But obviously if the HashMap changed then you would have to do those two operations over again which could get very costly.

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

Sidebar

Related Questions

I have data stored as below in an MS Access database: Date User 20090101
I have a database which contains picture data stored as a binary blob. The
I have a custom model, which internally uses HashMap<String, Object> to store the data.
I have objects with location data stored in Core Data, I would like to
I have the following scenario: I have various user's data stored in my database.
I have a data structure where an entity has times stored as an int
I have a text file where data is stored as columns. How do I
I have many objects reference the same class of stored data. In previous programs,
In a part of my data warehousing stored procedures, i have a procedure that
Are multi-threaded CLR stored procs possible? I have a data-intensive task with lots of

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.