I want to know how to control the console print format. My problem is that I have 2 threads, one of them constantly prints information to the console, and the other constantly asks the user to write information, but while writing if the other thread prints something, it cuts the phrase the user is writing and splits it. How do you control it?
My code of thread 1:
//Definition of variables
while (exit == false) {
scanner = new Scanner(System.in);
message = scanner.nextLine();
}
//Code to use user input
My code of thread 2:
//Definition of variables
while (receive.getExecutingState()) {
srvMsg = receive.Receive();
System.out.println(srvMsg);
}
Console output:
No more data to show.
No more data to show.
hNo more data to show.
eNo more data to show.
llo
I want it to keep printing messages while the user write data but don't split what it's writing.
Thanks in advance!
Edit: As said by @Thomas what I want in a clearer way, is to keep the text the user is writing at the bottom of the console, and the rest being updated.