Q: What are the possible results of attempting to compile and run the program?
a. Prints nothing.
b. Prints: [T1,A][T2,B].
c. Prints: [T1,B][T2,B].
d. Prints: [T2,B][T1,A].
e. Prints: [T2,A][T1,A].
f. Compiler error.
g. Run time error.
h. None of the above.
Answer is b c d e.
Expl: Since method m1 is not synchronized there is no guarantee that any one
thread will complete the method before another begins. Since the behavior of Thread.yield is implementation dependent there is no guarantee that control will be transferred to another thread. Even though the start method is invoked on thread T1 first there is no guarantee that it will actually begin to run first.
My Question : I was expecting b or d since the order can't be garunteed. What threw me off is T1,B and T2,A can happen. Isn't T1'S1 = A and T2's S1 = B. Where am I going wrong?
