Threadsafe vs Synchronized

前端 未结 7 1159
刺人心
刺人心 2021-02-02 11:01

I\'m new to java. I\'m little bit confused between Threadsafe and synchronized. Thread safe means that a method or class instance can be used by multiple threads at the same tim

7条回答
  •  -上瘾入骨i
    2021-02-02 11:35

    Thread safety is a desired behavior of the program, where the synchronized block helps you achieve that behavior. ​There are other methods of obtaining Thread safety e.g immutable class/objects. Hope this helps.

提交回复
热议问题