It will need to be multithreaded because the user
input will occur on a separate thread than the main
program thread.

The easiest way I know of to do this is to create a
lock object and then use the Object wait and notify
methods like in the code snippets below.

Tim

class MonopolyGame
{
  private Object lockObject = new Object();

  void mainLoop()
  {
    ......
    if(isHuman(currentPlayer))
    {
      // wait for them to click 'roll'
      synchronized(lockObject)
      {
        try
        {
          lockObject.wait(timeout);
        }
        catch(InterruptedException)
        {
           // this means you should clean up and 
           // prepare to exit
        }
        ........
      }
      (rest of method)
    }

    public void mouseEvent(Event)
    {
      if(isUserClicksRoll(event))
      {
        synchronized(lockObject)
        {
          lockObject.notify();
        }
      }
    }
 }
}


----------------------------------
Tim Bierbaum


 
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to