I changed your code a little, and it seems to work (two Threads, printing 3, 3, 5, 7):
I'm asking two things:
a) How is System.out working - a seperate
Thread?
b) In your example, the last access to theArray in the sync-block is via getSize ().
This is a indirect call to theArray.
The last direct call to theArray is before the big sleep happens, so perhaps the sync ends before the sleep?
I don't know the specs that exactly, to tell you whether this is a nice behaviour.
[ May 14, 2004: Message edited by: Stefan Wagner ]