What are synchronizing strategies for Prevayler?

后端 未结 2 921
名媛妹妹
名媛妹妹 2020-12-17 02:57

Prevayler guarantees that all the writes ( through its transactions) are synchronized. But what about reads?

Is it right that dirty reads are possible if no explic

2条回答
  •  無奈伤痛
    2020-12-17 03:49

    The recommended way is to use JMatch Query and Prevayler.execute(Query). Either directly or by using subclassing.

    The returned results must be either primitive values or immutable objects. If you plan to return mutable objects you should subclass JMatch Query to do these deep copies. This way you get a system that locks every sensible read with other (sensible) reads and writes. This can speed up and simplify development, especially for developers without multithreaded programming expirience.

    If you need more performance under high concurrent load, which is supposed to be a rare case, you indeed can use described above fine grained locking - using "synchronized" and java.util.concurrent.

    See this discussion for more details.

提交回复
热议问题