Everything you're asking for could be done on one thread. However, there are something things you should do before that. One thing I would consider doing is having a Table class that has a fixed number of clients. It could look something like
public final class Table {
private final Client[] clients = new Client[7];
public boolean contains(Client client) {
for (Client c : clients) {
if (c == client) {
return true;
}
}
return false;
}
public int indexOf(Client client) {
if (!contains(client)) {
return -1;
}
else {
for (int i = 0; i < clients.length; i++) {
if (clients[i] == client) {
return i;
}
}
}
}
public void add(Client client) throws IllegalArgumentException,
FullTableException {
if (client == null) {
throw new IllegalArgumentException("client must not be null");
}
if (contains(client)) {
throw new IllegalArgumentException(
"cannot add client to the table more than once");
}
if (available() > 0) {
clients[next()] = client;
// NOTE: You might want to announce to the other players that a new
// player has joined the game.
}
else {
throw new FullTableException();
}
}
public void remove(Client client) throws IllegalArgumentException {
if (!contains(client)) {
throw new IllegalArgumentException("table does not contain client");
}
clients[indexOf(client)] = null;
// NOTE: Announce to the other players that the player has left.
}
private int next() {
for (int i = 0; i < clients.length; i++) {
if (clients[i] == null) {
return i;
}
}
return -1;
}
}
Another thing you could do is add a "state" to each client, indicating if the client is at a table, in the lobby, etc.
I would
HIGHLY recommend avoiding creating one thread for each client. The more clients connect, the more resources will be used by trying to create a new thread for each one.
For choosing a table, all you would have to do is have the server send a packet to the client saying which tables are available. Then the client selects one, sends back the table number to the server, which then adds the client to the Table object designated by a certain number. For something as simple as this, I would suggest using the java.net classes. Since each player
MUST do an action (call, fold, raise) when it's their turn, having a blocking server should perform just fine.