logo       

Re: Question on JCIP annotations: msg#00018

java.jsr.166-concurrency

Subject: Re: Question on JCIP annotations

> 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; }
}


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise