Suppose you set up a custom annotation
public @interface ThreadSafe {
}
To indicate to the reader of your code that classes or methods are in fact Thread Safe
Other then a variant of a comment, how else can these types of custom annotations be used?
If you're just asking about potential applications of such an annotation, here's a few off the top of my head...
EventBus
uses an @AllowConcurrentEvents
annotation as a hint for its EventBus
framework. @ThreadSafe
to make sure they are, in fact, thread safe. Such annotations can bring information that could be used to improve the efficiency of algorithms. The RandomAccess interface is used for this purpose.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.