You didn't do anything wrong. The reason you see such result is because... well, because that's how it is. Since both threads run parallely then there's a race condition. There's not much you can do about it, because you don't have control over the order of threads (it's up to OS).
Try running the code few times and you should see the opposite result from time to time.