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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:08:39+00:00 2026-06-02T13:08:39+00:00

I have a large ArrayList of objects similar to the following class Entry {

  • 0

I have a large ArrayList of objects similar to the following

class Entry {
    private String variable1 = null;

    private int variable2 = 0;

    public Entry (String variable1) {
    this.variable1 = variable1;
    }

   /* getters and setters for variable1 and 2 are below */
}

I initiate the objects in the ArrayList, then create multiple threads. Each thread searches a large set of documents to determine if the contents of variable1 is embedded in the document. If it is, I want to make a copy of the Entry, specific to the thread, similar to below:

public Entry(Entry entry) {
    this(entry.getVariable1())
  }

I then want to alter the contents of variable2 of the Copy not the original. To summarize:

  1. The objects values are initialized prior to threading.
  2. The objects are shared (read only) by multiple threads.
  3. When an object needs to be modified, a copy of the object is made and changes are made to the copy.

Here are my questions.

  1. Do getters and setters for variable1 and variable2 need to be synchronized. Since I am only reading the objects when shared between threads, this seems unnecessarily but please correct me if I am wrong.
  2. Is there a better way to share a large arraylist of information. (I don’t want to copy the arraylist for each thread because it is huge with greater than 200K objects)?
  • 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-02T13:08:40+00:00Added an answer on June 2, 2026 at 1:08 pm
    1. If you make a copy of the objects stored in your read-only shared array than there is no need to synchornize getters/setters.

    2. Your approach seems to be fine as long as the list is read only

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

Sidebar

Related Questions

I have the following code in Java: public class ServerInfo { int serverId; int
I have this resource allocator class public class ResourceAllocator { ArrayList<Request> queue = new
Consider I have large library package with sophisticated tree of private or package modules
I have a fairly large chunk of code that produces/returns an arraylist of search
I have defined an ArrayList in my main class where I am loading data
List<String> flowers = new ArrayList<String>(); My for loop currently looks like this... for (int
I have an ArrayList , which I want to divide into smaller List objects
I have a very large response from server of JSON string. I converted it
I have a large string that contains fixed value fields, this group of fields
I have a large list of objects, all of whom have a path to

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.