summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/immutable/Traversable.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/scala/collection/immutable/Traversable.scala')
-rw-r--r--src/library/scala/collection/immutable/Traversable.scala11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/library/scala/collection/immutable/Traversable.scala b/src/library/scala/collection/immutable/Traversable.scala
index 5fc0607a00..3d4ba95a16 100644
--- a/src/library/scala/collection/immutable/Traversable.scala
+++ b/src/library/scala/collection/immutable/Traversable.scala
@@ -18,6 +18,17 @@ import mutable.Builder
/** A trait for traversable collections that are guaranteed immutable.
* $traversableInfo
* @define mutability immutable
+ *
+ * @define usesMutableState
+ *
+ * Note: Despite being an immutable collection, the implementation uses mutable state internally during
+ * construction. These state changes are invisible in single-threaded code but can lead to race conditions
+ * in some multi-threaded scenarios. The state of a new collection instance may not have been "published"
+ * (in the sense of the Java Memory Model specification), so that an unsynchronized non-volatile read from
+ * another thread may observe the object in an invalid state (see
+ * [[https://issues.scala-lang.org/browse/SI-7838 SI-7838]] for details). Note that such a read is not
+ * guaranteed to ''ever'' see the written object at all, and should therefore not be used, regardless
+ * of this issue. The easiest workaround is to exchange values between threads through a volatile var.
*/
trait Traversable[+A] extends scala.collection.Traversable[A]
// with GenTraversable[A]