It is because both threads (main and t1) are synchronized on same reference. Thread t1 will not be in "running" state unless main thread comes out of synchronized block. And by that time it has modified the contents of string array.
If you remove any of synchronized block, 900 milliseconds are sufficient (although it is not a guarantee) to t1 to run. So you may not always get "XYZ" in that case.
Hope this helps. Nandu
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss