I have a scanner in my main method that waits for a response. Is there any way I can close the scanner after a period of time with no response? I believe I am able to do this with an additional thread but I do not know if there is a better way. Any help is appreciated, thanks!
String input;
Scanner playerInput;
playerInput = new Scanner(System.in);
input = playerInput.nextLine();