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 :-(");
}
}