001/* 002 * Copyright 2009-2014 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2009-2014 UnboundID Corp. 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021package com.unboundid.util; 022 023 024 025/** 026 * This enumeration defines a set of thread safety levels that may be used to 027 * indicate whether the associated code is safe to be accessed concurrently 028 * by multiple threads. 029 */ 030@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 031public enum ThreadSafetyLevel 032{ 033 /** 034 * The associated code is completely threadsafe and may be accessed 035 * concurrently by any number of threads, subject to the constraints described 036 * in the {@link ThreadSafety} documentation. 037 */ 038 COMPLETELY_THREADSAFE, 039 040 041 042 /** 043 * The associated code is mostly threadsafe, but there may be some methods 044 * which are not safe to be invoked when multiple threads are accessing an 045 * instance concurrently. The class-level documentation for a class including 046 * this thread safety level should include comments indicating which methods 047 * are not threadsafe, and those methods should also be marked with their own 048 * {@code ThreadSafety} annotations using the {@link #METHOD_NOT_THREADSAFE} 049 * level. 050 */ 051 MOSTLY_THREADSAFE, 052 053 054 055 /** 056 * The associated code is mostly not threadsafe, but there may be some methods 057 * which are safe to be invoked concurrently by multiple threads. The 058 * class-level documentation for a class including this thread safety level 059 * should include comments indicating which methods are threadsafe, and those 060 * methods should also be marked with their own {@code ThreadSafety} 061 * annotations using the {@link #METHOD_THREADSAFE} level. 062 */ 063 MOSTLY_NOT_THREADSAFE, 064 065 066 067 /** 068 * The associated code is not threadsafe. Unless otherwise noted, multiple 069 * threads may not attempt to invoke methods on the same instance of objects 070 * of this type without external synchronization. 071 */ 072 NOT_THREADSAFE, 073 074 075 076 /** 077 * Methods declared in the associated interface or abstract class must be 078 * threadsafe in classes which implement that interface or extend that 079 * abstract class. No guarantees will be made about the thread safety of 080 * other methods contained in that class which are not declared in the parent 081 * interface or superclass. 082 */ 083 INTERFACE_THREADSAFE, 084 085 086 087 /** 088 * Methods declared in the associated interface or abstract class are not 089 * required to be threadsafe and classes which call them must not rely on the 090 * ability to concurrently invoke those methods on the same object instance 091 * without any external synchronization. 092 */ 093 INTERFACE_NOT_THREADSAFE, 094 095 096 097 /** 098 * The associated method may be considered threadsafe and may be invoked 099 * concurrently by multiple threads, subject to the constraints described in 100 * the {@link ThreadSafety} documentation, and in any additional notes 101 * contained in the method-level javadoc. 102 */ 103 METHOD_THREADSAFE, 104 105 106 107 /** 108 * The associated method may not be considered threadsafe and should not be 109 * invoked concurrently by multiple threads. 110 */ 111 METHOD_NOT_THREADSAFE 112}