writing data to console at the same time printinf information in java
One way would be to read the character from the users one by one:
- let the writing thread write
- if user enters one character (or more) pause the writing thread until the user presses enter
- when the user presses enter, resume the writing thread
The pause/resume mechanism could be done in several ways, for example by using a Sempahore
with one permit that is taken by the reading thread or the writing thread in turn.