I ran at San Fermin in 2007. It is among the scariest things I have done, but quite an experience.
There is a double bend early in the course where it goes through a large plaza. Our plan was to start before that plaza, run to that, so that we could hop out if we needed to. Since it is unpredictable I would recommend planning something like that. Get a map of the route the day before, and plan out some good places to hop out if it seems you're about to be trampled.
You want to plan because it will be crazy once the run starts, and if you aren't prepared, you may be in for trouble.
Don't be stupid
It's a fun event, and it seems that just about everyone has stayed up all night drinking and now wants to share the street with some confused and enormous bulls that have no traction. If you want to party, do it every other night except the one before you run. You have to be there so early anyways (I believe we woke up around 4:30AM to get there on time).
Don't run WITH them
Find a way to get behind the bulls and follow them to the arena. Out of our group of about 5-6 people, two of us hopped out and stayed behind, the rest were able to safely avoid the bulls and follow them into the arena. When you see people get gored, they are running in front of, or right alongside the bulls.
In the arena at the end, just watch
Once the bulls get to the bullfight arena, everyone that comes in is antagonizing and "fighting" the bulls, as if they were matadors. You'll have plenty to watch without injuring yourself.
You can have plenty of fun without endangering your life. Assuming you don't live there and will be making a trip for it, there's no reason to be maimed for a little excitement to prove how daring you can be.