Here's a warning to anyone who's thinking of using threads - don't bother. Even if you've used them before, I think it serves well to be reminded (me included) that they should be avoided at all costs. Why? Because they make things exponentially more complicated!
Programming is complicated enough, trying to write a block of code that has zero bugs and defects. But what about if the variables you are using could change in mid-line? Or objects that you thought existed because you checked in the previous line now don't exist in the next line?
My multi-player games use at least two running threads; one is the main game loop, and another is the thread that waits for connections from players. This can cause problems in itself - the main game loop obviously loops through the players collection to send them data (and other stuff), but a player can join the game regardless of what stage the main game loop is at. So problems exist in that the main game loop could send all the players the current (say) ammo levels, but if a player had only just joined, they hadn't even been told that a particular unit exists in order to have a gun to contain the ammo!
Unfortunately, the keyboard input is also a seperate thread (as is the norm with Java), and until I corrected it, I was performing IO operations inside the KeyPressed() method. So the client software code could be halfway through sending the unit's location, when the player decide to press space to shoot, and suddenly a stream of bytes representing the "Shoot" command comes steaming through, completely confusing the server. The synchronised keyword fixed this problem of course.
This is just a few minor examples of threading problems. The irony is, that on the face of it threads seem like a great idea - like lots of little programs all doing their own thing. Unfortunately, it's when they have to interact with each other, which they always have to at some time, that problems start.