Search code examples
javaconsole-applicationuser-inputwaitelapsedtime

How can I run my code during waiting user input


I am making a game in Java console. I want to show elapsed time, waiting input from user. I can't run any code waiting input. How can I run my codes during input wait?


Solution

  • You can create new Thread, define what it should do and start it.

    Docs:

    https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html

    Check docs for java version you need. These are for version 7.

    Also I suggest you to get some knowledge about parallel programming and using threads. There are plenty of material on the internet