How can I run my code during waiting user input

149 Views Asked by At

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?

1

There are 1 best solutions below

0
Wortig On BEST ANSWER

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