I was given a question in class saying 'What are the possible final values of a? (Assume that each statement is a unit of execution. You do not need to consider the problem at the instruction level.)'. With additional information:
Thread A: a = 3 (A1) and a = a + 1 (A2)
Thread B: a = 5 (B1) and a = a + 7 (B2)
So after some thought that First thread output should be 4 and second threads output should be 12.
So I did the test script to see if that's correct and output shows what I expected Thread A: 4 and Thread B: 12.
The question is, should I expect other values? Or maybe I'm just implementing this question wrong? How I can tweak this code to get other values, if possible? Is that a tricky question, or its just me?
EDIT: Since code was not really needed for my homework assignment, lets focus on theoretical implementation of such problem.