001 package edu.rice.cs.cunit.threadCheck;
002
003 import java.lang.annotation.Retention;
004 import java.lang.annotation.RetentionPolicy;
005 import java.lang.annotation.Target;
006 import java.lang.annotation.ElementType;
007
008 /**
009 * Annotation for a class or method signaling that it should only be run by the designated threads.
010 *
011 * The preferred method is using value and an array of @ThreadDesc annotations. This, however,
012 * can be mixed with the other ways of specifying threads, although they may not support more advanced
013 * features. The thread and thread group names are treated as regular expressions. You may not specify
014 * eventThread=true in more than once place.
015 *
016 * @author Mathias Ricken
017 */
018 @Retention(RetentionPolicy.CLASS)
019 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
020 public @interface OnlyRunBy {
021 /** Describes selection of the event thread. */
022 public static enum EVENT_THREAD {
023 /** Event thread not selected. */
024 NO,
025 /** Only event thread may run after a component has been realized (for use with @OnlyRunBy). */
026 ONLY_AFTER_REALIZED,
027 /** Only event thread may run (for use inside @OnlyRunBy). */
028 ONLY
029 }
030
031 /** @return array of thread descriptions. */
032 ThreadDesc[] value() default {};
033
034 /** @return array of regular expressions for thread names that may exclusively run the annotated class or method. */
035 String[] threadNames() default {};
036
037 /** @return array of thread ID numbers as returned by Thread.getID(), designating the threads
038 * that may exclusively run the annotated class or method. */
039 long[] threadIds() default {};
040
041 /** @return array of regular expressions for thread group names that may exclusively run the annotated class or
042 * method. */
043 String[] threadGroups() default {};
044
045 /** @return true if the event thread may exclusively run the annotated class or method. */
046 EVENT_THREAD eventThread() default EVENT_THREAD.NO;
047 }