In this example, if you enter text, it will be transferred in pieces with the output. How to make the typed text remain in place when outputting from a stream.
import java.util.Scanner; class testThread implements Runnable{ @Override public void run() { for(int i=0;i<1000;i++){ System.out.println("LOG message"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } } class test { public static void main(String[] args) { Scanner in = new Scanner(System.in); new Thread(new testThread()).start(); while (true){ String str = in.nextLine(); System.out.println(str); } } }