java method synchronization and read/write mutual exclusion

后端 未结 5 1463
醉酒成梦
醉酒成梦 2021-02-01 05:28

I have two methods read() and write() as below in a class.

class Store
{

  public void write()
  {
    // write to store;
  }

  publi         


        
5条回答
  •  礼貌的吻别
    2021-02-01 05:30

    Take care to read this article:

    https://blog.takipi.com/java-8-stampedlocks-vs-readwritelocks-and-synchronized/

    • RWLocks can be slow especially when there are many readers to writers
    • synchronized is on average the most reliably fast
    • there are new locks like StampedLock

提交回复
热议问题