Read X = 0 by both the threads Thread1 and Thread2
Complete all the instructions of one thread except the last, i.e Thread2 runs the loop 15 times doing x = x+5, so just execute the first 14 and Store back the modified value of X. Since the initial value of X = 0 was read by both the threads, Thread1 still holds 0 for X.
Initiate the looping statement of Thread1. After running it for the first time X = 3, and store it back.
Now we have one last time for Thread2(Since we ran it for 14 times initially, instead for 15). Read X, i.e 3.
After reading the value of X by Thread2, complete the loop of Thread1.
Now in Thread2 increment X by 5 and Store it back. The final value of X thus obtained will be 8.