I have a multi thread java console application. One of the threads is reading input from the user while other prints to the console some data. The problem shows up when the writer thread print something while user is typing an input. It interrupts the user.
I wrote "\r" to the beginning of output to clear the line for a better looking. However, I also want to print to the next line what user typed until that moment.
For example, I want to type 123456 as input. But when I typed 123,
>123
The writer threads prints "OUTPUT".
>OUTPUT
>
I want to show what I typed before("123") and then I will type the remaining input.
>OUTPUT
>123
I was suggested to use jLine. But I couldn't achieved it. Can you help me by providing example usage of jLine library or suggesting an alternative solution?
It is important to not block the writer thread. It must print the output when it arrived.