JAVA: How do I accept input during a certain period of time only

Posted by sebrock on Stack Overflow See other posts from Stack Overflow or by sebrock
Published on 2010-04-30T16:15:34Z Indexed on 2010/04/30 16:17 UTC
Read the original article Hit count: 164

Filed under:
|
|
|
|

Im trying to do a simple game where I continually need input from players. This needs to happen during a certain time period only. Everything that is sent after that will be discarded. After the time period a new game starts. So:

  1. Start game
  2. Wait for input from all players during 10 seconds
  3. > 10 secs no more input
  4. Calculate the winner and do some stuff
  5. Goto 1.

I was thinking using a timer and timertask to keep track of time and maybe use a boolean variable that changes from "open" to "closed" after 10 seconds? Please give me some advise on this.

© Stack Overflow or respective owner

Related posts about java

Related posts about timer