39

造成HashMap非线程安全的原因-Ala6的博客

 5 years ago
source link: http://blog.51cto.com/13982920/2341658
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
在前面我的一篇总结文章中提到,为了数据能在线程范围内使用,我用了 HashMap 来存储不同线程中的数据,key 为当前线程,value 为当前线程中的数据。我取的时候根据当前线程名从 HashMap 中取即可。因为当初学习 HashMap 和 HashTable 源码的时候,知道 HashTable 是线程安全的,因为里面的方法使用了 synchronized 进行同步,但是 HashMap 没

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK