Java assignment issues - Is this atomic?

前端 未结 4 1711
刺人心
刺人心 2021-02-14 22:01

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

  • Strings

I\'ve got a class:

public class Test {
 private String s;

 public synchro         


        
4条回答
  •  独厮守ぢ
    2021-02-14 22:28

    Perhaps a Read Write Lock could solve your problem?

    Take a look at its documentation:

    A read-write lock allows for a greater level of concurrency in accessing shared data than that permitted by a mutual exclusion lock. It exploits the fact that while only a single thread at a time (a writer thread) can modify the shared data, in many cases any number of threads can concurrently read the data (hence reader threads). In theory, the increase in concurrency permitted by the use of a read-write lock will lead to performance improvements over the use of a mutual exclusion lock. ....

提交回复
热议问题