Review Request: CR 7100996 - (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
Ulf.Zibis at CoSoCo.de
Thu Jun 21 16:12:05 UTC 2012
I would understand, what is meant.
Looks good to me.
Am 21.06.2012 17:59, schrieb Jim Gish:
> Please review the proposed spec change to StringBuffer below, which informs the user about
> additional thread safety issues as described in the bug. (Thanks to Brian for the language).
> diff -r 46ff1b63b0c3 src/share/classes/java/lang/StringBuffer.java
> --- a/src/share/classes/java/lang/StringBuffer.java Mon Jun 11 07:10:48 2012 -0400
> +++ b/src/share/classes/java/lang/StringBuffer.java Thu Jun 21 11:45:51 2012 -0400
> @@ -63,6 +63,14 @@
> * appending or inserting from a source sequence) this class synchronizes
> * only on the string buffer performing the operation, not on the source.
> * <p>
> + * While StringBuffer is designed to be safe to use concurrently from
> + * multiple threads, the source data passed to append/insert, if shared
> + * across threads, must ensure that StringBuffer.add/insert has a
> + * consistent and unchanging view of the source data for the duration of
> + * the operation. This could be done by the caller holding a lock during
> + * the add/insert call, or because the source data is immutable, or because
> + * the source data is not shared across threads.
> + * <p>
> * Every string buffer has a capacity. As long as the length of the
> * character sequence contained in the string buffer does not exceed
> * the capacity, it is not necessary to allocate a new internal
More information about the core-libs-dev