Hi there:
I'm trying to work on a server application which is part of a game.
If you've created or helped to create server applications before please
read on.

I wanted the game to be networkable over the Net. I've come across a
small snag however. When the application first launches it runs a
function called execute(). In this function is this line of code:
players[i] = new Player(server.accept(), this, i);
This line of code is inside a for loop and is used to create player
objects everytime someone logs onto the server app via a Client applet.
In this case the game only allows for two players so the players[] array
has only two indexes.

For clarity, the Player object has the following constructor:

public Player(Socket s, JBattleShipsServer server, int num)
currentPlayer = (num == 0 ? "Player1" : "Player2");
connection = s;

InputStream is = connection.getInputStream();
System.out.println("InputStream for " + currentPlayer + " is "
+ is.toString());
input = new DataInputStream(is);
output = new DataOutputStream(connection.getOutputStream());
catch(IOException e)
control = server;
number = num;

Now, there is nothing wrong with any of this code except the fact that
the server app also has a menu bar with some drop down menus which
cannot be accessed while the execute() function is running. You see,
what happens is that when the execute() function runs and reaches the
line: players[i] = new Player(server.accept(), this, i);
the entire application is suspended (brought to a grinding hault) until
two individuals log on via the Client applet. Only then, does the for
loop finish executing, the rest of the code in execute() continues to
run, the game commences, and I'm able to access the menus on the menu
bar. This is not acceptible. I need to access the menus on the menu bar
whether there is anyone logged on and playing a game or not! If anyone
has had a similar experience in designing a server app, please provide
some ideas for a workaround.