Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda