If you think they are about to throw something then you can try to distract them, that may involve asking them a question about the thing they are holding that requires an answer or directing them towards using the toy in a way they weren't thinking about - for example "can you drive your car to the shops?" or "what colour is your car?" Or do something entirely different (tickling is excellent if your child happens to be ticklish).
If that doesn't work then if you get to them in time then remove the object, take it away from them and put it both out of reach but also somewhere visible. Remind them that the behaviour is bad.
Should they become obstinate or just start throwing things without warning then it's time to start the time-out process. If they're unlikely to hurt others this will involve a count (I normally use 3, some use 5) and then a trip to the time-out spot/chair/step if the behaviour doesn't change. If they have a near-miss, hurt others or damaged something then the lack of a count reinforces that the act they have committed is more serious.
Once you've decided to put them in timeout then they cannot negotiate their way out and should get no contact (don't even look at them if you don't have to) until the time (around 1 minute for each year of age) is finished. We jokingly say that "we do not negotiate with terrorists!".
If they leave the spot you've put them in then timeout begins again. If they persist in moving then they may need to be held in timeout until the time is up, and if so that should be done without talking to them and with minimal eye-contact. I've had my 3-year-old do 30 minutes before now... but we are the adults and our resolve will always be stronger.
Once the timeout is finished then you can explain to them why they were excluded (older children should be asked why and pressed for an answer) and that you would rather have fun than do timeouts. Make it clear that you love them but that you disapprove of the behaviour and they should say sorry to you and anyone they've upset or hurt. This is a really important part, because it is where the education happens.
At this point you get back to having fun, it's important to do this as, no matter how angry with them you may be, you have to work on toddler-time which runs much faster than adult time. Equally, they may be a repeat offender and it's important to remember that while we link the events of 30 minutes ago, they might not and it might take a few time-out trips for them to link the bad behaviour with a timeout.
For each setting there should be a consistent set of expectations that are consistently (rigidly) enforced by everyone who cares for the child and eventually you'll get good behaviour. Good enough anyway...