"Mark Space" <> wrote in message
news:5Ncdj.33005$ et...
> Karl wrote:
>
>> One would hope that the VM specification would sufficiently constrain the
>> variations such that developers in most cases could write to the Java
>> threading model, and not be concerned about the platform. Are there any
>> articles or white papers describing specific situations where this is not
>> the case?
>
> Yes, even basic books mention this. Learning Java by O'Reilly mentions
> that not all JVM support preemptive multitasking. The JLS does the
> opposite of what you hope. It pushes the responsibility for using threads
> correctly in all environments onto the programmer. The JLS spec on
> threads is a lot less defined than you are assuming.
>
> http://java.sun.com/docs/books/jls/t...ml/memory.html
>
> Now I haven't read all of that, because I haven't had to deal with
> complicated multi-thread apps yet, but at least I know it exists and where
> to find it.
Fascinating. I have been programming professionally in Java for about 10
years now, so I do not read the "basic books" very much anymore. Perhaps it
is time for a refresher course
In my early Java days (JDK 1.1), if I ever encountered write-ups on these
issues, I must have failed to take notice. That being said, I have written
some massively scalable server applications that run under Windows, Solaris
and Linux, and except for having to specify green threads to make things
work in Linux, I can recall no platform-specific threading problems. These
applications involve lots of network and file I/O and general data
processing.
The only thing I can conclude from that is that I must either (a) have an
innate sense of how to use threads "correctly" (whatever that means across
platforms), or (b) I have simply lucked into designs that just happen to
work on all three platforms. Perhaps a combination of the two, but I don't
want to give myself too much credit here.
I have rarely had the need to go beyond the simple "synchronized" block and
wait/notify constructs. In the entire time between JDK 1.1 and JDK 1.5, I
think I was obliged to hand-code one mutex. Since JDK 1.5, I have rarely
needed to dip into the concurrency packages, even while continuing to be
called upon to produce heavily concurrent, multi-threaded applications.
Furthermore, I have few UI problems as long as I adhere to the Swing
threading model design patterns.
Just my experience with the Java threading API.