Relationship between Threads and println() statements

前端 未结 2 1149
别跟我提以往
别跟我提以往 2020-12-20 15:46

I was trying to create a few scenarios to demonstrate visibility issues while sharing variable across threads. And I noticed that in almost all the cases I tested, if inside

2条回答
  •  星月不相逢
    2020-12-20 16:48

    This behaviour is implementation specific. In OpenJDK, println's body is synchronized altough the API does not state that it is.

提交回复
热议问题