Reputation: 101
Is the guava bloom filter in 18.0 thread safe. On other words, can I have multiple threads share a Bloom Filter instance and use myBloomInstance.mightContain and myBloomInstance.put concurrently. Thank you for your help
Upvotes: 0
Views: 1593
Reputation: 46482
No, you must synchronize.
You can split in into a few parts if you need concurrency. There's
com.google.common.util.concurrent.Striped
which makes it pretty easy.
And as always, you can fill it and only read it in another thread, assuming that you do a save publication.
The BloomFilter
is thread-safe in the current Guava version:
https://github.com/google/guava/commit/6092a4a8b1087f92d0c3169b9e96d53c54ca95c4
Upvotes: 4