1   /*
2    * %W% %E%
3    *
4    * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
5    * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6    */
7   
8   package java.util;
9   
10  /**
11   * This exception may be thrown by methods that have detected concurrent
12   * modification of an object when such modification is not permissible.
13   * <p>
14   * For example, it is not generally permissible for one thread to modify a Collection
15   * while another thread is iterating over it.  In general, the results of the
16   * iteration are undefined under these circumstances.  Some Iterator
17   * implementations (including those of all the general purpose collection implementations
18   * provided by the JRE) may choose to throw this exception if this behavior is
19   * detected.  Iterators that do this are known as <i>fail-fast</i> iterators,
20   * as they fail quickly and cleanly, rather that risking arbitrary,
21   * non-deterministic behavior at an undetermined time in the future.
22   * <p>
23   * Note that this exception does not always indicate that an object has
24   * been concurrently modified by a <i>different</i> thread.  If a single
25   * thread issues a sequence of method invocations that violates the
26   * contract of an object, the object may throw this exception.  For
27   * example, if a thread modifies a collection directly while it is
28   * iterating over the collection with a fail-fast iterator, the iterator
29   * will throw this exception.
30   *
31   * <p>Note that fail-fast behavior cannot be guaranteed as it is, generally
32   * speaking, impossible to make any hard guarantees in the presence of
33   * unsynchronized concurrent modification.  Fail-fast operations
34   * throw <tt>ConcurrentModificationException</tt> on a best-effort basis. 
35   * Therefore, it would be wrong to write a program that depended on this
36   * exception for its correctness: <i><tt>ConcurrentModificationException</tt>
37   * should be used only to detect bugs.</i>
38   *
39   * @author  Josh Bloch
40   * @version %I%, %G%
41   * @see     Collection
42   * @see     Iterator
43   * @see     ListIterator
44   * @see     Vector
45   * @see     LinkedList
46   * @see     HashSet
47   * @see     Hashtable
48   * @see     TreeMap
49   * @see     AbstractList
50   * @since   1.2
51   */
52  public class ConcurrentModificationException extends RuntimeException {
53      /**
54       * Constructs a ConcurrentModificationException with no
55       * detail message.
56       */
57      public ConcurrentModificationException() {
58      }
59  
60      /**
61       * Constructs a <tt>ConcurrentModificationException</tt> with the
62       * specified detail message.
63       *
64       * @param message the detail message pertaining to this exception.
65       */
66      public ConcurrentModificationException(String message) {
67      super(message);
68      }
69  }
70