> Someone
> suggests me to use a thread to check constantly inside the method

        Me. ;)

> Loop
>     Check mouse position
>     IF mouse position is in the area, do something
>     ELSE do nothing
> End Loop

        Sure, you can do exactly that in Java; just the way you mentioned
it.
        while (true) {
          // check mouse position
          if (/whatever/) {
            ...
          } else {
            ...
          }
        }

        But you are now blocking everything else that is going on in your
program.  That if/else statement will have to call a series of functions
that check absolutely everything that is going on in your program.
        If you want something complicated to happen near the mouse, your
going to notice the rest of your program stop.

> Since I am worring about the thread that will make our program
> unreliable or unstable, therefore I rarely use thread.

        Threads don't make programs unreliable or unstable.  Poorly
written threads do.  As long as you are careful, threads will make your
program much more reliable for what you are looking to do.

> The main reason
> is that since I am trying to make a very simple RTS game, so if mouse
> moving thread is stop responding or a bit slow because of the CPU time
> or whatever, it will make the game not synchronized.  If I use C/C++ way
> that dose not use fork, check everything in one flow, it gurantees the flow.

        Command and Conquer uses threads.  I promise. ;)
        If you process everything in a single thread, imagin that the
computer player has 500 units and is trying to decide where to move them
next.  Let's say it takes 1 millisecond to decide where a single unit
goes.  Everytime you process your loop, your program will block for half a
second -- the user will be able to do nothing and graphics will jerk
around.
        If this was a turn based system, a single thread might be able to
hack it.  But if you want to put together a RTS that runs smoothly, you'll
need *multiple* threads.

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to