Hi...so I'm busy messing around with threads and I decided to make a small game.It's not working well so far though.My cat thread isn't running.Also I'm not sure that I've used wait() and notify() correctly.
The idea is that I create a Mouse and cat class.Then I create a single Cat and multiple Mouse threads.When a mouse is created it gets put in a static hash map.I use math.random() in the Cat thread to create a random chance of the cat catching(and killing) a mouse.Not quite sure how I should go about this..Oh yes..also the idea is that there should only be one mouse running around at a time.The game is meant to end either when cheese=0 OR when the mice have all been killed... I just can't seem to get the Cat thread to output anything....any suggestions??
[ December 29, 2008: Message edited by: Duran Harris ]
Your program had several issues... 1) The program was freezing because everyone was waiting at the cat monitor 2) You forgot to interrupt the mouse thread once you killed it 3) The static HashMap approach wasen't really working
Here is a version of the program that seens to be working allright for me:
ps: There is a game development forum here at the saloon .
[ December 29, 2008: Message edited by: Anthony Accioly ] [ December 29, 2008: Message edited by: Anthony Accioly ]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com