Re: Thread safety documentation
On Tue, 9 Mar 2010, markspace wrote:
Arved Sandstrom wrote:
Patricia Shanahan wrote:
The "Calendar.getInstance() thread safe?" is yet another instance of a
recurring problem with Java APIs, the lack of consistent documentation
and default rules for thread safety. Often, these questions can only
be resolved by examination of the source code, which is unsatisfactory
because it is vulnerable to future changes that would preserve
everything that is documented.
I now have some free time, and would like to try to contribute to a
resolution of the problem. Is there an existing effort I should join,
or do I need to start a new one?
If it's simply a matter of documentation, it seems to me that JCIP made a
good start with Appendix A, Annotations for Concurrency.
I agree with you. However in one of the "public contribution" phases of Java
7, I suggested this and it was rejected out of hand. I don't believe Sun
understands or agrees with the need for this sort of documentation.
I should add that I suggested these annotations be added to the core
language, like @Override is, and they rejected it because they felt these
annotations should be part of the Java doc controls and an API issue rather
thanu a language feature.
I happen to disagree with them.
No, you happen to be right!
I think that the compiler could check thread
safety correctness, according to declared annotations, and it would be a big
benefit for Java programmers.
It would. But i rather doubt it's practical - how exactly would the
compiler do that? On the face if it, that sounds like a very hard
(halting-problem-hard) thing to prove in general.
I'm not sure what the effort involved would be, but I'm sure it's less
than debugging threading issues in all Java programs in existence.
I'm not.
(Note I didn't suggest all this, just that they get the JCiP annotations
in the language so folks could start using them.)
I wouldn't be surprised if they'd rejected the idea including compiler
proof. But the annotations seem so uncontroversial and obviously a good
idea that i'm shocked that they weren't considered.
Oh and to answer Patricia's original request, no I don't know of any
thread safety efforts related to Sun's API. If you find some, Patricia,
please let us know. I'd be interested in contributing to the effort
myself.
Does the fact that OpenJDK is, er, open make this any different? Is there
now some committee of open source regents who can make a fresh decision to
look at this? Or is Sun still in charge of the spec, and so able to rule
out new ideas?
On ths subject of the halting problem, i came across this the other day:
http://www.ling.ed.ac.uk/~gpullum/loopsnoop.html
Which i thought was quite entertaining.
tom
--
the meaning is the illocutionary force of interrogativeness with no
propositional content -- Geoffrey K. Pullum