Skip to content

Commit

Permalink
PriceProvider: Add volatile to cachedResult field
Browse files Browse the repository at this point in the history
The get() and put() calls can happen on different threads. The volatile
keyword makes sure that all updates to cachedResult are visible to all
threads.

Relates to bisq-network#33.
  • Loading branch information
alvasw committed Nov 16, 2023
1 parent 6073a39 commit 451a030
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/bisq/price/PriceProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public abstract class PriceProvider<T> implements SmartLifecycle, Supplier<T> {

protected final Duration refreshInterval;

private T cachedResult;
private volatile T cachedResult;

public PriceProvider(Duration refreshInterval) {
this.refreshInterval = refreshInterval;
Expand Down

0 comments on commit 451a030

Please sign in to comment.