Suddenly a thought occurred to him.
A thought crossed his mind all of a sudden.