System.out.println and System.err.println out of order

后端 未结 7 1209
灰色年华
灰色年华 2020-11-22 03:44

My System.out.println() and System.err.println() calls aren\'t being printed to the console in the order I make them.

public static         


        
7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 04:21

    I have used thread to print the output of System.out and System.err sequentially as:

        for(int i = 0; i< 5; i++){
            try {
                Thread.sleep(100);
                System.out.print("OUT");
                Thread.sleep(100);
                System.err.print("ERR");
            }catch (InterruptedException ex){
                System.out.println(ex.getMessage());
            }
        }
    

提交回复
热议问题