There are already very good ideas/advice on this thread. In my experience, our thoughts tend to feed back into themselves, be they negative or positive. It's very easy to get trapped in the negative thoughts loop/spiral. The good news is that it works just the same way with positive thoughts (I don't really like the expression "positive thinking", I'm using it for lack of a better term, maybe I should say "feeling good").
Already being in a negative state, I find that relying upon external stimulus (or even internal ones, like trying to focus on images and things that make us happy) can definitely help break the cycle. In these situations, all of the suggestions above are very good, pick the ones that work for you or find new ones and try them out until you find something that works. I like to sing, to listen to music (music has a very powerful effect), to dance, to watch a funny or inspiring movie. Smiling works very well for me too. Just smiling at people on the street, even when you don't really feel like it. In fact, I've made smiling frequently a habit many years ago. I'm not sure how this works, it could be that by doing that we trick our brains, or when you smile at other people they usually smile back at us and that makes us feel good... I really don't know, all I know is that it works for me - and the more I smile, the more I feel like smiling.

I even use smilies a lot on written communication. lol
But in order to avoid getting in the negative spiral/loop, I think it's important to become aware of the signs and do something about it before it traps you. You can condition yourself to avoid this, and more importantly, you can learn to be positive "by default". This takes a lot more work, I can tell you that in advance, but it is well worth the effort. There are different approaches to this and I'm new to this myself - again, different things work for different people. But basically, you should try to learn how to recondition your way of thinking. I'm not going into personal details here, but trust me, it took me A LOT of practice to be able to change my thought patterns. And I'm still in the process, but I'm here to tell you it is possible and it is really worth the effort.
Someone mentioned gratitude. To me this works wonders. After watching "The Secret" I started making it a habit to start my day thinking about the things I'm grateful for. It really puts you in a positive state, like it's already been said, helps you focus on being happy about what you already have instead of focusing on what you don't have (which would probably trap you in the negative loop). That doesn't mean you shouldn't want other things, but by feeling happy and grateful for what you already have you are allowing the positive mindset to set in.
But anyway, whenever you feel like you're starting to get in the negative thoughts loop, act immediately and go do something that makes you feel good. Try hard to replace the negative thoughts with positive ones. Think about what you're grateful for. Put on some music. Whatever works for you, try different things, but act. It might feel "fake" in the beginning, but in time, it will help to recondition your thought patterns. I hope this helps, it sure has helped me, so I felt like sharing. Good luck to you.