>>> Hi,
>>>
[quoted text clipped - 30 lines]
> assume that the interleaved execution of multiple threads will proceed in
> the the most inconvenient and malicious way possible.
It is even more complicated than that.
You must assume that all actions that aren't otherwise synchronized
might appear in some unexpected order to another thread.
For example:
if you have
public int a,b,c;
and Thread 1 code is:
a = 10;
b = 3*a;
c = a*b;
Thread 2 might see at any time a=0, b=0, c=0. Or a=10, b=0, c=300. Even
if thread 2 waits for c != 0, changes to a and b might not be visible to
it, so you would see a=0, b=0, c=300.
Understanding concurrency isn't as difficult as some people make it
sound, but there are quite a few subtleties to learn. My usual
suggestion is to read the book Java Concurrency In Practice:
<http://virtualinfinity.net/wordpress/technical-book-recommendations/java-concurr
ency-in-practice/>
This book if full of a complete and intuitive explanation of all of the
current Java Concurrency features, including Java 1.5 concurrency framework.
Hope this helps,
Daniel.

Signature
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
Ravi - 26 Nov 2007 05:51 GMT
Yep. At least I figured out that I should read Java Concurrency in
practice. :)
Thanks a lot Owen, Matt, Daniel.
Regards,
Ravi.
On Nov 23, 11:04 pm, Daniel Pitts
<newsgroup.spamfil...@virtualinfinity.net> wrote:
> >>> Hi,
>
[quoted text clipped - 60 lines]
> --
> Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>