Eric gives Joe three apples. Joe eats two. How many apples does Joe have?
One, you think?
But you have no idea how many apples Joe had before.
Moral of the story: initialize your variables.
Joe has three apples. Eric gives him three more. Joe eats two. How many apples does Joe have?
Four? Of course not. He has six, because he ate those two yesterday.
Moral: synchronize your threads.
Joe has five apples. He eats two. How many apples does Joe have?
Three? Wrong again. He ate somebody else's apples.
Moral: protect your address space.
Eric gives Joe five apples. Joe eats them.
The next day Eric wants his five apples back, because he was only storing them with Joe.
Moral: read your requirements specification.