Passing Command Line Arguments to a new Thread
Johannes Blume via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Aug 7 12:08:35 PDT 2014
On Thursday, 7 August 2014 at 18:38:37 UTC, Marc Schütz wrote:
> But this shouldn't be necessary, right? It's a mutable slice to
> immutable data, but the slice is passed by value, so no mutable
> sharing takes place.
The elements of the slice itself are mutable, you can e.g. assign
some other string to args[1], which would be a potentially racy
change among all threads which share that slice. Only the
information "start address of slice" and "length of slice" are
copied by value, which doesn't protect from this.
To be able to share the slice, it would need to be typed as
"immutable(string)[]" instead.
More information about the Digitalmars-d-learn
mailing list