Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
How to update an array in a class which is changed by some other thread?

I've run into a problem which is, when I create a thread( of some other class) in a class, it takes an array of that class as a parameter for its constructor and changes it later in its run() function. How can I update the array in the class that creates the thread (i.e. to update the changes made by the thread)?

// public serverInit()
public connection[] myservers;
public void Threads()
{
  Thread accept=new Acception(myservers);
  accept.start();
}

// public class Acception extends Thread


public void run()
{
  try
  {
     while(true)
       {
        client = server.accept();
        if(client.isConnected())
        {
             for(int i=0;i<totalServers;i++)
            {

              String[] info=client.getInetAddress().toString().split(":");
                if(info[0].compareToIgnoreCase(myservers[i].getIp())==0)    
                {
                    myservers[i].setStatus("Active");
                    System.out.println("Request Received From server : " + 
                     client.getRemoteSocketAddress());
                    Thread work=new server(client);
                    work.start();
                    break;
                }
            }
         }
        }
       }
       catch(Exception e)
      {
         System.out.println("Connection with 
              "+client.getInetAddress().toString()+" failed :-(");
        }
     }
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!