Are non-synchronised static methods thread safe if they don't modify static class variables?

后端 未结 5 816
悲哀的现实
悲哀的现实 2020-11-28 17:20

I was wondering if you have a static method that is not synchronised, but does not modify any static variables is it thread-safe? What abou

5条回答
  •  粉色の甜心
    2020-11-28 18:24

    A method can only be thread-unsafe when it changes some shared state. Whether it's static or not is irrelevant.

提交回复
热议问题