An article on IBM DeveloperWorks on 5 myths about Java programming:
Myth 1: Garbage collection solves all memory-related problems
Myth 2: Parameters are passed by reference
Myth 3: Atomic operations are thread safe
Myth 4: Synchronized code is the same as a critical section
Myth 5: Waiting threads are awakened in priority order
There was a bit of a surprise for me in this article: Threads can keep their own copies of object variables. So you can assign a value to a variable in one thread and even though that line has executed that doesn't mean another thread reading the same variable will see it. But that isn't so unexpected Certainly with regular code optimizations with registers to hold variables one would expect this sort of thing to happen. It is hard to tell from the article whether Java takes this further than what one would expect to see in just compiled C that did the same thing.
Posted by Randall Parker at November 14, 2002 10:50 AM