interthread communication

hi

I am developing a game but since it is a very naive game it is not multithreaded except when a missile is fired from the spaceship. There is a seperate thread for the missile and in this thread ofcourse the collision between missile , hindereances and alien spaceship is detected. Now the problem is that this thread had to "notify" the thread that spawned it (the main thread of the game) that it has destroyed a ship and this destruction might result in end of the game as one might win/lose.. Now i was to ask how this missile thread is going to notify to the main thread that a destruction of the spaceship has happened so that the main thread should decide to end or continue the game. But one thing is that the main thread wont be waiting on the condition of "lives" of a space ship to finish.. so i cant use notify()/wait () combination

so what to do.. hwo thread communicate in this situation

thanks

[935 byte] By [sharkeea] at [2007-10-2 3:20:13]
# 1

JDK 1.5 package java.util.concurrent has a class Exchanger

http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Exchanger.html

Which is described as:

A synchronization point at which two threads can exchange objects. Each thread presents some object on entry to the exchange method, and receives the object presented by the other thread on return

In past game development, we commonly used a centralized "Game Manager" called an Arbitrator. All actions by characters, or autonomous objects (like your missles), register their "move/action" with the Arbitrator. The Arbitrator maintains the rules of the game and can confirm or deny the requested action by the actor due to game rules (like missle cannot signal DETONATE because the Arbitrator says the missle was already destroyed by a laser and is STATE_DEAD). The arbitrator can also signal the actors of events that effect them. For example the Arbitrator could signal SpaceShip1 that it just took 100 damage. That way SpaceShip1 can take note of this information and react accordingly according to the AI.

logician007a at 2007-7-15 21:47:40 > top of Java-index,Administration Tools,Sun Connection...
# 2
I AM WORKING ON THREADS AT INTIAL STAGES HERE I NOT UNDERSTAND THAT HOW WE USE THESE THREADS TO CAPTURE THE RESOURSES .SO PLZ ANY ONE LIKE TO PROVIDE ME THE CODE FOR INTER THREAD COMMUNICATION .THANKS
begginera at 2007-7-15 21:47:40 > top of Java-index,Administration Tools,Sun Connection...