@ThreadSafe
public class A
{
}
Does this annotation actually make the class Thread Safe or is it just for readability?
@ThreadSafe
public class A
{
}
Does this annotation actually make the class Thread Safe or is it just for readability?
Place this annotation on methods that can safely be called from more than one thread concurrently. The method implementer must ensure thread safety using a variety of possible techniques including immutable data, synchronized shared data, or not using any shared data at all.
It does not make the class Thread Safe, the programmer does it Thread Safe and adds the annotation.
You might want to see this helpful link too.
The @ThreadSafe
annotation is used:
The annotation does not change the way the code itself operates, and putting it on a class that does not guarantee thread safety is a mistake.