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

后端 未结 5 824
悲哀的现实
悲哀的现实 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 17:59

    String objects being immutable is another reason for thread-safe scenario above. Instead if mutable objects are used (say makeMutableArray..) then surely thread-safety will break.

提交回复
热议问题