Ryan Beckett wrote:In scenarios 1 and 2, the main method executed first, and in the 3rd it waits until both client threads are finished. If you run scenario 1 and 2 more, the output should change. Threads are unpredictable.
thanks Ryan, i got the idae .....
one more thing ... in the 3rd scenario the main thread will wait until other two threads finish and both methods are synchronized so each thread(one and two) loop will run 1000 times. this implies , the loop will run 2000 times but the output is between 1000 and 2000 why is that?