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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:23:11+00:00 2026-06-15T17:23:11+00:00

I am implementing a multi-threaded program in Java, where each thread is of a

  • 0

I am implementing a multi-threaded program in Java, where each thread is of a type class Node extends Thread.

All these classes generate certain values which will be used by other classes.

For main it’s easy to get the values from the generated threads, but from within threads itself, how can I get the values on other threads?

//Start the threads from a list of objects
for (int i = 0; i < lnode.size(); i++) { 
    lnode.get(i).start();
}

thanks

  • 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-15T17:23:13+00:00Added an answer on June 15, 2026 at 5:23 pm

    If you do something like:

    class MyThreadRunnable implements Runnable {
        List<String> strings;
    
        MyThreadRunnable(List<String> strings) {
            this.strings = strings;
        }
    
        public void run() {
            strings.add(getName());
        }
    }
    
    // ...
    
    List<String> sharedStrings = new ArrayList<String>();
    Thread t1 = new Thread(new MyThreadRunnable(sharedStrings));
    Thread t2 = new Thread(new MyThreadRunnable(sharedStrings));
    
    t1.start();
    t2.start();
    

    then both t1 and t2 (two different threads of the same type) will be using the same list, and see changes to it made from the other thread.

    Actually, since I’m not using any synchronisation for brevity, it’s also possible this would corrupt the list in some unpredictable way and cause weird errors. I strongly encourage you investigate process synchronisation, and the java.util.concurrent package when working with concurrency.

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

Sidebar

Related Questions

How should implement multi-thread in single-threaded Operating system using java? Java supports Multi-threading.Is there
For my university class we are developing a multi-threaded Blackberry application which allows us
Possible Duplicate: Java: “implements Runnable” vs. “extends Thread” I have two questions about multithreaded
Currently, I am implementing a multi-thread project using std::thread in C++11. I use std::condition_variable
I have a class implementing an interface, which has a multi-parameter constructor, and a
I'm implementing multi-threading in my ObjC program via NSBlockOperation. Some of the method calls
I am implementing simple version of TCP, but lack of multi-thread technique. The main
When implementing Serializable interface, in Java, we need to set it's serialVersionUID long. Is
Given multi-tenant application, How are vendors implementing email notifications from an email account setup
I'm implementing StructureMap in a multi-tenant ASP.NET MVC application to inject instances of my

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.