I am making a game in which I am accepting input using the Scanner class. I have added the Timer and TimerTask class. When the question is displayed, it waits for the user to enter the answer. What I want is, if the user doesn't give an input, in say 10 seconds, the program should move to the next question and if the user answers, it should accept the input. The problem with my code is that it is not moving to the next question but is waiting for an input. Can anyone help please?
Asked
Active
Viewed 440 times
1
-
2Please consider showing your code. – Hovercraft Full Of Eels Aug 10 '15 at 14:18
-
Did you try to check [this link](http://stackoverflow.com/questions/5853989/time-limit-for-an-input) – SomeJavaGuy Aug 10 '15 at 14:21
-
I'm not an expert, but what about an ansynchronous task, which runs a while true loop, and constantly checks the current time - input time. And an if statement that breaks the loop and returns to the main thread and runs a specific method when this time exceeds a limit. – Aug 10 '15 at 14:22