Receive input in specific time
<p>I'm writing a testing system and i all i want to do is to count how many seconds had user spent on this question. i.e. i print question(standard System.out.println), then wait 5 seconds and if within these 5 seconds user answered(through standard input), i want to keep this value. 
If user hasnt provided an answer in 5 seconds, it must skip this question and continue. 
The problem is - im reading user answers via Scanner object, and something like in.nextInt() is uncontrollable, i suppose.</p>

<p>How can i solve this problem? Here is fragment of my code without that functionality, can you give me some hints what to add?</p>

<pre><code>    public void start() {
    questions.prepareQuestions(numQuestions);
    Scanner in=new Scanner(System.in);
    boolean playerIsRight=false,botIsRight=false;
    int playerScore=0,botScore=0;
    for (int i = 0; i &lt; numQuestions; i++) {
        questions.askQuestion(i);
        System.out.print("Your answer(number): ");
        playerIsRight=questions.checkAnswer(i,in.nextInt()-1); //in.nextInt() contains the answer
        botIsRight=botAnswersCorrectly(i + 1);
        if(playerIsRight){ playerScore++; System.out.println("Correct!");}
        else System.out.println("Incorrect!");
        if(botIsRight) botScore++;
        System.out.print("\n");
    }
    if(botScore&gt;playerScore) System.out.println("Machine won! Hail to the almighty transistors!");
    else if(playerScore&gt;botScore) System.out.println("Human won! Hail to the power of nature!");
    else System.out.println("Tie. No one ever wins. No one finally loses.");
}
</code></pre>
