[concurrency-interest] Question on JCIP annotations

Brian Goetz brian at quiotix.com
Thu Oct 12 11:10:21 EDT 2006


> Agreed - I realize it's a corner case and just wanted to ask for some
> clarification (with an eye towards Findbugs). @ThreadSafe makes more sense
> when @Immutable implies multiple objects.

Also, bear in mind that a class with static methods only might still not 
be thread-safe if they have shared mutable state that is not properly 
synchronized.  For example:

@NotThreadSafe
public class FooFactory {
   private static int fooCount;

   public static Foo newFoo() {
     ++fooCount;
     return new Foo();
   }

   public static getFooCount() { return fooCount; }
}


More information about the Concurrency-interest mailing list