Java assignment issues - Is this atomic?

前端 未结 2 1330
自闭症患者
自闭症患者 2021-02-14 21:54

I\'ve got some questions about Java\'s assigment.

  • Strings

I\'ve got a class:

public class Test {
 private String s;

 public synchro         


        
2条回答
  •  没有蜡笔的小新
    2021-02-14 22:26

    Rather than wrapping your HashMap in something to make it synchronized, consider using a java.util.concurrency.ConcurrentHashMap instead.

    This is an updated version of HashMap that guarantees "Retrievals reflect the results of the most recently completed update operations holding upon their onset.".

提交回复
热议问题