Is multi-thread output from System.out.println interleaved

后端 未结 4 922
青春惊慌失措
青春惊慌失措 2020-11-22 08:19

If multiple threads call System.out.println(String) without synchronization, can the output get interleaved? Or is the write of each line atomic? The API makes no mention of

4条回答
  •  -上瘾入骨i
    2020-11-22 08:40

    Just to clarify, say you have two threads, one that prints "ABC" and another that prints "DEF". You will never get output like this: ADBECF, but you could get either

    ABC
    DEF 
    

    or

    DEF
    ABC
    

提交回复
热议问题