-
Enhancement
-
Resolution: Unresolved
-
P3
-
None
-
1.2.0, 5.0, 6
-
Cause Known
-
x86, sparc
-
solaris_2.5, solaris_10, windows_xp
The class and method descriptions should describe whether the object can be operated on by multiple threads concurrently, or whether methods can be called concurrently by multiple threads.
This doc bug has a corollary javadoc tool bug 4078855 that states that javadoc should be modified so it does not print the keywords "synchronized"
or "native" in the method signatures.
It's important for the developer to know whether it's safe for multiple threads
to operate on an object concurrently,. To this end, it is important for the general class description and method descriptions to describe whether the object is thread-safe or not. However, this synchronization can be implemented either in public methods or in private methods, and the Java Platform API spec should not declare one to be preferred over the other. A licensee should be able to achieve synchronization internally if they wish.
Example 1: java.util.Enumeration interface - A single Enumeration cannot be used by multiple threads concurrently.
Example 2: java.util.HashTable class - An instance of HashTable cannot be
used by multiple threads concurrently.
Reason: Even assuming that Hashtable should be thread-safe, there's no reason that we should tell people that we're achieving this by synchronizing all of its exported methods. We should reserve the right to synchronize internally at the bucket level, thus offering higher concurrency. (Geeks take note: the auto-grow functionality of Hashtables may prevent us from taking advantage of this specific suggestion, but you get the idea.) - Josh Bloch
This doc bug has a corollary javadoc tool bug 4078855 that states that javadoc should be modified so it does not print the keywords "synchronized"
or "native" in the method signatures.
It's important for the developer to know whether it's safe for multiple threads
to operate on an object concurrently,. To this end, it is important for the general class description and method descriptions to describe whether the object is thread-safe or not. However, this synchronization can be implemented either in public methods or in private methods, and the Java Platform API spec should not declare one to be preferred over the other. A licensee should be able to achieve synchronization internally if they wish.
Example 1: java.util.Enumeration interface - A single Enumeration cannot be used by multiple threads concurrently.
Example 2: java.util.HashTable class - An instance of HashTable cannot be
used by multiple threads concurrently.
Reason: Even assuming that Hashtable should be thread-safe, there's no reason that we should tell people that we're achieving this by synchronizing all of its exported methods. We should reserve the right to synchronize internally at the bucket level, thus offering higher concurrency. (Geeks take note: the auto-grow functionality of Hashtables may prevent us from taking advantage of this specific suggestion, but you get the idea.) - Josh Bloch
- duplicates
-
JDK-6433082 Threadsafety no mentioned in API documentation?
-
- Closed
-
-
JDK-6338363 Clearly mark all non-thread safe classes and methods in API
-
- Closed
-
- relates to
-
JDK-4078855 javadoc template: Keywords "synchronized" + "native" shouldn't appear in HTML si
-
- Closed
-
-
JDK-6202942 (spec thread) ThreadLocal example should use generics and autoboxing
-
- Resolved
-