sleep method of Thread eventually hangs forever :(
First some background on my project:
I'm developing a simple game in order to learn Java, and it is two player. A Player is a child of Thread, and the thread continually reads from the player's input buffer (an array list) and processes movements.
A ComputerPlayer is a child of Player and it makes random moves and also reads from it's input buffer (also an array list).
A HumanPlayer is also a child of Player, but it only has a Pressed method which accepts a KeyEvent as a parameter.
As this game is two player and real time, both player's threads execute simultaneously.
The Game object implements KeyListener and waits for human input. If the input is a key that does something, it passes that KeyEvent to HumanPlayer's Pressed method, and HumanPlayer adds that key press to its input buffer.
The Problem:
Now, my problem is that the ComputerPlayer runs for a bit making moves and such, but then the thread completely freezes after a call to sleep. About 5 calls to sleep work, but then somewhere around the 6th call, the thread will not wake up again. (I used some echo statements to find out that the thread does not wake up from a call to sleep)
I'm using Debian Linux and JDK version 1.6.0_01.
Any suggestions? I'd greatly appreciate any.
Message was edited by:
toroid
Message was edited by:
toroid
Message was edited by:
toroid

