Consider the use of simple classes like String and Integer. One of the
original motivations for declaring these classes as immutable wass for
the sake of thread safety.
Should there be two versions, one of which uses synch in its constructor
and one not? Or should people put synch blocks only when constructing
those that the believe might be accessible across threads? Or what?
No answers along these lines strike me as tolerable.
I think the only choice here is for the semantics to guarantee safety.
Compilers can optimize away barriers when they can prove lack of
visibility across threads. Luckily there has been some significant
progress along these lines, that apply even to hostile programming
environments :-) such as alphas. OOPSLA will have three papers on
escape analysis techniques that I believe could be used to kill a
large enough percentage of unnecessary barriers so that this is no
longer a massive impediment to obtaining good performance. (This is
just a belief though. I haven't seen any empirical results wrt
barriers; only locks.)
-- Doug Lea, Computer Science Department, SUNY Oswego, Oswego, NY 13126 USA firstname.lastname@example.org 315-341-2688 FAX:315-341-5424 http://gee.cs.oswego.edu/ ------------------------------- This is the JavaMemoryModel mailing list, managed by Majordomo 1.94.4.
To send a message to the list, email JavaMemoryModel@cs.umd.edu To send a request to the list, email email@example.com and put your request in the body of the message (use the request "help" for help). For more information, visit http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:13 EDT