i want to print to console while waiting for input. Can this be done with multi-threading? If so, i dont know how to multi-thread. I need help!
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
use this code:
Then just call this when you want to start the input:
Now you have a thread that reads inputs while the main thread is free to print to screen
EDIT: be sure to only call the thread once!
I am not sure if I understand your question but this is possible solution. There are two new threads created in main method. First read from console and write text back to it and second is only counting down from 50 to 0 and writing to console actual number: