How to fix race condition without using synchronized block?

后端 未结 0 855
长情又很酷
长情又很酷 2021-01-25 23:56

Have a scenario where multiple threads have race condition on comparison code.

private int volatile maxValue;

public getNextValue() {
  int latestValue = ...;
           


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题