1

java newbie here, i am a little bit stuck about a case.

My program will generate a random question to user, and user only have time for let's say just 5 seconds to answer it.

boolean passedTimeLimit = false;
System.out.println("Question 1 : what is the product of 24566771 multiply 9121315?");
String ans1 = input.readLine(); //Timer here waiting for input

if (passedTimitLimit) {
   // 5 points
} else {
   // 10 points
}

What is the simplest approach to set the timer here?

I've been googling around about it, but it seems that everyone using class timer for this, i personally think it's overkill, maybe.

(i repeat, i have googling around to find a simple solution for this case, not a solution using Timer or TimerTask, not BlockingQueue either)

deckamaha
  • 33
  • 1
  • 6

0 Answers0