how to update interface to MainActivity from thread activity in different class?
<p>now i'm making socket connection to connect multiple client to one server. everything fine, i make thread in different class. But when i will fill textView with string from thread activity, i can't. please help </p>

<p>this MainActivity:</p>

<p>public class MainActivity extends Activity {</p>

<pre><code>private static int port = 6000;
TextView txt;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    txt = (TextView) findViewById(R.id.txtCommand);
    txt.setText("Server : ");
    ServerSocket server1 = null;
    Server gameServer = new Server();
    try {
        server1 = new ServerSocket(port);
        // .. server setting should be done here
    } catch (IOException e) {
        System.out.println("Could not start server!");
       // return ;
    }

    while (true) {
        Socket client = null;
        try {
            client = server1.accept();
            gameServer.handleConnection(client);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

public class Server  {
    private ExecutorService executor = Executors.newCachedThreadPool();

    public void handleConnection(Socket client) throws IOException {    
        PlayerConnection newPlayer = new PlayerConnection(this, client);
        txt.setText(newPlayer.getuname());
        this.executor.execute(newPlayer);
    }

    // add methods to handle requests from PlayerConnection
}
</code></pre>

<p>and this thread adctivity :</p>

<p>public class PlayerConnection implements Runnable {
    private Server parent;</p>

<pre><code>private Socket socket;
private PrintWriter out;
private BufferedReader in;
String line;

protected PlayerConnection(Server parent, Socket socket) throws IOException {
    this.parent = parent;
    this.socket = socket;

    this.in = new BufferedReader(new InputStreamReader(socket
            .getInputStream()));
    this.out = new PrintWriter(new OutputStreamWriter(
            socket.getOutputStream()));     
}

public void run() {
    while(!this.socket.isClosed()) {                        
        try {
            //int nextEvent = this.in.readInt();
            line = in.readLine();
            System.out.println("Server Receive : "
                    + line);
            out.println("Server Sent :" +line);
            System.out.println("SEND : "
                    + line);
            out.flush();
             if (line == null){
                 this.socket.isClosed();
                 break;
             }
        } catch (IOException e) {}
    }
</code></pre>
