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
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com