# Java ThreadSafe

**URL:** <https://community.sonarsource.com/t/java-threadsafe/44322>\
**Category:** SonarQube Cloud\
**Tags:** collections, threadsafe, google, java\
**Created:** [June 5, 2021, 12:59am UTC](https://community.sonarsource.com/t/java-threadsafe/44322 "2021-06-05T00:59:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MomEngineer](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/momengineer/32/17899_2.png) [@MomEngineer](https://community.sonarsource.com/u/MomEngineer)\
**Post date:** [June 5, 2021, 12:59am UTC](https://community.sonarsource.com/t/java-threadsafe/44322/1 "2021-06-05T00:59:30Z")

</div>

Sonar is complaining that marking a collection field `volatile` is not enough to make it thread safe - which is true in general, but it seems like it does not accept `ImmutableSet` from Google collections as a valid thread safe implementation - is it somehow configurable?

We are using [sonar-scanner-cli-4.5.0.2216.zip](https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.5.0.2216.zip)

---

<div class="post-metadata">

**Author:** ![dmeneses](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dmeneses/32/2933_2.png) [@dmeneses](https://community.sonarsource.com/u/dmeneses)\
**Post date:** [June 7, 2021, 8:08pm UTC](https://community.sonarsource.com/t/java-threadsafe/44322/2 "2021-06-07T20:08:03Z")

</div>

Hi!  
What are the versions of SonarQube and SonarJava that you’re using?  
Could you also post relevant code snippets?

---

<div class="post-metadata">

**Author:** ![BaboonOnTree](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/baboonontree/32/22850_2.png) [@BaboonOnTree](https://community.sonarsource.com/u/BaboonOnTree)\
**Post date:** [June 7, 2021, 9:07pm UTC](https://community.sonarsource.com/t/java-threadsafe/44322/3 "2021-06-07T21:07:47Z")

</div>

As MomEngineer wrote, we use command line Sonar client 4.5.0.2216. There is nothing special in the snippet, it is just a plain Java class with public mutable fields marked with volatile. We use [SonarCloud.io](http://SonarCloud.io) so I don’t know how to provide the exact SonarQube version which is hidden under the hood.
