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
  • 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-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 a set of XSDs from which I generate data access classes, stored
I have some data stored as ArrayList . And when I want to backup
We have data stored in oracle 10g db which contains french character set. The
I have my data stored in a MySQL table, which includes an auto_increment ID
I have a set of data stored in text files, which I have now
I have some data stored on client side which I need to fetch thru
I have a custom model, which internally uses HashMap<String, Object> to store the data.
Greetings, I have data stored on mysql with delimiter , in 1 table. I
If you have geographic data stored in ESRI shapes, you have at least three
I have a collection of data stored in XDocuments and DataTables, and I'd like

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.