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