Próbuję zrobić prosty program klient-serwer. Serwer ma komunikować ze sobą dwóch klientów.
Na razie mam taki kod:

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.*;


public class Serwer {

	public static void main(String[] args) {
		ServerSocket ss = null;
		Socket[] s = new Socket[2];
		int nrK = 0;
		Watek w[] = new Watek[2];
		DataOutputStream output;
		
		try {
			ss = new ServerSocket(1000);
		} catch (IOException e) {
			e.printStackTrace();
		}
		while (true) {
			try {
				//if (nrK < 2) {
					s[nrK] = ss.accept();
					output = new DataOutputStream(s[nrK].getOutputStream());
					if (nrK == 0) output.write(126);
						else if (nrK == 1) output.write(127);
					System.out.println("Połączono z klientem: " + nrK);
					w[nrK] = new Watek(s[nrK], nrK);
					w[nrK].run();
					nrK ++;
				//}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}

import java.io.*;
import java.net.*;


public class Watek extends Thread {
	Socket s;
	byte bufor;
	DataInputStream input[] = new DataInputStream[2];
	DataOutputStream output[] = new DataOutputStream[2];
	int nrK;
	
	public Watek(Socket s, int nrK) {
		try {
			input[nrK] = new DataInputStream(s.getInputStream());
			output[nrK] = new DataOutputStream(s.getOutputStream());
		} catch (IOException e) {
			e.printStackTrace();
		}
		this.s = s;
		this.nrK = nrK;
	}
	
	public void run() {
		while(true) {
			try {
				bufor = input[nrK].readByte();
				System.out.println(nrK + " " + bufor);
			} catch (IOException e) {
				e.printStackTrace();
			}
			
		}
	}
	
}

Problem polega na tym że łączę pierwszego klienta i komunikaty są od niego odbierane przez serwer ale nie mogę połączyć drugiego klienta. Ale gdy nie uruchamiam wątku dla połączonego klienta to wtedy klient drugi łączy się bez problemów. Jak to poprawić żeby można było podłączać dwóch klientów?