I think it's exactly what i need, but i don't understand how does it work.
Then read Using millis() for timing. A beginners guide, Several things at the same time and look at the BlinkWithoutDelay example in the IDE.
If you have any problems with the program that you write then post it here for help