My subconscious mind grinds on the problem in the background without me having to exert any real effort thinking about it, until it finally finds a solution and raises an interrupt in my conscious mind.
This process has become so effective, that if I can spot a problem coming, I say to myself, "I should figure out how to solve X", and don't think about it. A few days later when I come back to it, as if by magic, I have a solution already starting to form.
This is the same phenomenon that causes you to wake up in the middle of the night with an answer to a question you were thinking about earlier in the day... usually, "who sings this blasted song?"
The brain is an amazing, complicated, wonderful thing.