Closed alvasw closed 10 months ago
Every ExchangeRateProvider
starts its own Timer
running on its own background thread. When many clients call the REST API at the same time, several threads from the server thread pool handle the requests concurrently. Without the volatile
keyword these threads could return a stale state because the last updates are not visible to them yet.
Timer / Background Thread Creation: https://github.com/bisq-network/bisq-pricenode/blob/6073a3948e7567359adf9f167c27d65a7e352d9a/src/main/java/bisq/price/PriceProvider.java#L69-L81
ACK
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 #33.