Threadsafe vs Synchronized

前端 未结 7 1158
刺人心
刺人心 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:48

    In practice, performance wise, Thread safe, Synchronised, non-thread safe and non-synchronised classes are ordered as:

    Hashtable(slower)  <  Collections.SynchronizedMap  <  HashMap(fastest)
    

提交回复
热议问题