I'm always amused by the sorts of answers you get when a question comes up of naked human aggression. Particularly when it comes in a form which conforms to a lot of people's worse fears about loss of control, crowds, implicit race or class and all the related symbolism.
The first thing that comes to mind is that these attacks resemble attacks by barracudas. For those who don't know to some divers in tropical waters a school of barracudas is more frightening than sharks. Barracudas are fast and evil looking and it is easy to imagine that a dozen coming at you at once would be impossible to defend against. If it goes down like in the stories your meat.
The question is if barracudas are so formidable how can other fish exist? Why are so few divers attacked and why do so many survive the attack.
Which begs a few questions:
If human swarm attacks are so frequent and deadly why do so many otherwise defenseless denizens of the inner urban utopia, such as it is, continue to exist? Look around any inner city and you see a lot of inhabitants. Most of these people are fairly weak. Presumably easy targets. But even among this collection of weaklings very few are attacked and most of those attacked survive. Why?
I don't know for sure, and I think there is a lot of randomness and chance involved, but I can offer a few thoughts:
Attacks are not entirely random. A lot of gang and group idiocy is centered around times when young-adults are free and drunk or high and at times and places where there are not a lot of people in authority around.
My understanding is that Friday and Saturday nights within a few hours either way of the closing times for the bars is peak time for all sorts of felonious assaults of all descriptions. On the other end early Sunday mourning is the time least likely for such behavior. On week days trouble rises after schools are out and peaks at the closing time for the bars. Safest time is early morning at about dawn.
Used to be police also knew when during a month the worse weekends would be. It was no great feat. Welfare checks came out on the fifth of each month. The young bucks would emerge from the woodwork and get their cut of the check from their girlfriend/s.
If it fell on a Friday or Saturday the police knew it would be a particularly busy night. There would be the usual fights as the bucks renegotiated their cut with the mother of their children. Then more fights as the bucks negotiated transfer of funds from government checks to cash and still more as the funds were converted into drugs and alcohol. Then, with a belly full of their inebriant of choice and fresh from three weeks of slow partying as the bars close the bucks hit the street looking to make it a memorable night.
Times have changed some. Welfare checks don't come out all at once and the credit card benefits are harder to convert into any form of sustenance a young buck might crave. Which isn't to say there aren't patterns. Just different ones.
Just knowing the signs and patterns of the streets you can lower the risk considerably by timing when your out. Talking to inner city kids they know this even if they can't tell you in so many words.
There are a lot of factors. Like what motivates an attack? What does the individual and group gain? What are they afraid of and what do they avoid. Drunks and derelicts get beat up but most survive and there is certainly no shortage of them. How and why?
Understand this and your chances of surviving go up.
If you see the your best chance as running try to consider how groups move. Lacking any better option a corner is better than being caught in the open. If they have to come at you one at a time it takes longer and there is more chance of both defending yourself and of the followers getting tired, bored or losing enthusiasm. Remember that most businesses and homes have a back door so running in the front serves many purposes. A crowd has trouble getting through a doorway.
If you run into a house or business, even if you have to kick the door, your involving the residents. These are likely to object to your entry but so to to a large number of people following you. The residents your involving are locals who may have more leverage with the people following.
Don't stop to talk. Think about using anything available to slow down the oncoming crowd. Make noise. Keep going right out the back door. Repeat as necessary. Keep going until you are well clear of the neighborhood. If you get away they may keep looking for you.
One final word: Beware trying to be a hero. Joke is that hero is a sandwich and an accolade assigned posthumously. There isn't enough glory in the world to make up for the going down part of 'going down in a blaze of glory'. It is easy to muse on about your standing in Valhalla but in the end there are only two categories that count: Those that survived and those that didn't.
After the fact you can make up any lie you wish about how you fought like a lion against twenty to one odds and well told it might get you a beer or two but you have to survive the event to drink the beer. Calculate your odds carefully and do what you need to do to survive. A lot of bold talkers reconsider when faced with the actual event. Which is how so many bold talkers stay alive. This is not a time to worry about playing a part in a hero fantasy.
If, in the end, you think attack is the best route ... good luck. Do it if it is the best way to survive. Don't do it with the idea that anyone will be impressed.