Enum ThreadSafetyLevel

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<ThreadSafetyLevel>

    public enum ThreadSafetyLevel
    extends java.lang.Enum<ThreadSafetyLevel>
    This enumeration defines a set of thread safety levels that may be used to indicate whether the associated code is safe to be accessed concurrently by multiple threads.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      COMPLETELY_THREADSAFE
      The associated code is completely threadsafe and may be accessed concurrently by any number of threads, subject to the constraints described in the ThreadSafety documentation.
      INTERFACE_NOT_THREADSAFE
      Methods declared in the associated interface or abstract class are not required to be threadsafe and classes which call them must not rely on the ability to concurrently invoke those methods on the same object instance without any external synchronization.
      INTERFACE_THREADSAFE
      Methods declared in the associated interface or abstract class must be threadsafe in classes which implement that interface or extend that abstract class.
      METHOD_NOT_THREADSAFE
      The associated method may not be considered threadsafe and should not be invoked concurrently by multiple threads.
      METHOD_THREADSAFE
      The associated method may be considered threadsafe and may be invoked concurrently by multiple threads, subject to the constraints described in the ThreadSafety documentation, and in any additional notes contained in the method-level javadoc.
      MOSTLY_NOT_THREADSAFE
      The associated code is mostly not threadsafe, but there may be some methods which are safe to be invoked concurrently by multiple threads.
      MOSTLY_THREADSAFE
      The associated code is mostly threadsafe, but there may be some methods which are not safe to be invoked when multiple threads are accessing an instance concurrently.
      NOT_THREADSAFE
      The associated code is not threadsafe.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ThreadSafetyLevel forName​(java.lang.String name)
      Retrieves the thread safety level with the specified name.
      static ThreadSafetyLevel valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static ThreadSafetyLevel[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • COMPLETELY_THREADSAFE

        public static final ThreadSafetyLevel COMPLETELY_THREADSAFE
        The associated code is completely threadsafe and may be accessed concurrently by any number of threads, subject to the constraints described in the ThreadSafety documentation.
      • MOSTLY_THREADSAFE

        public static final ThreadSafetyLevel MOSTLY_THREADSAFE
        The associated code is mostly threadsafe, but there may be some methods which are not safe to be invoked when multiple threads are accessing an instance concurrently. The class-level documentation for a class including this thread safety level should include comments indicating which methods are not threadsafe, and those methods should also be marked with their own ThreadSafety annotations using the METHOD_NOT_THREADSAFE level.
      • MOSTLY_NOT_THREADSAFE

        public static final ThreadSafetyLevel MOSTLY_NOT_THREADSAFE
        The associated code is mostly not threadsafe, but there may be some methods which are safe to be invoked concurrently by multiple threads. The class-level documentation for a class including this thread safety level should include comments indicating which methods are threadsafe, and those methods should also be marked with their own ThreadSafety annotations using the METHOD_THREADSAFE level.
      • NOT_THREADSAFE

        public static final ThreadSafetyLevel NOT_THREADSAFE
        The associated code is not threadsafe. Unless otherwise noted, multiple threads may not attempt to invoke methods on the same instance of objects of this type without external synchronization.
      • INTERFACE_THREADSAFE

        public static final ThreadSafetyLevel INTERFACE_THREADSAFE
        Methods declared in the associated interface or abstract class must be threadsafe in classes which implement that interface or extend that abstract class. No guarantees will be made about the thread safety of other methods contained in that class which are not declared in the parent interface or superclass.
      • INTERFACE_NOT_THREADSAFE

        public static final ThreadSafetyLevel INTERFACE_NOT_THREADSAFE
        Methods declared in the associated interface or abstract class are not required to be threadsafe and classes which call them must not rely on the ability to concurrently invoke those methods on the same object instance without any external synchronization.
      • METHOD_THREADSAFE

        public static final ThreadSafetyLevel METHOD_THREADSAFE
        The associated method may be considered threadsafe and may be invoked concurrently by multiple threads, subject to the constraints described in the ThreadSafety documentation, and in any additional notes contained in the method-level javadoc.
      • METHOD_NOT_THREADSAFE

        public static final ThreadSafetyLevel METHOD_NOT_THREADSAFE
        The associated method may not be considered threadsafe and should not be invoked concurrently by multiple threads.
    • Method Detail

      • values

        public static ThreadSafetyLevel[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (ThreadSafetyLevel c : ThreadSafetyLevel.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ThreadSafetyLevel valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • forName

        public static ThreadSafetyLevel forName​(java.lang.String name)
        Retrieves the thread safety level with the specified name.
        Parameters:
        name - The name of the thread safety level to retrieve. It must not be null.
        Returns:
        The requested thread safety level, or null if no such level is defined.