My question is: as i understand if you are a bad person in this life you pile up a ton of negative karma which will lead to miserable circumstances in the next life like cruel parents, birth in the poor country and that entails bad upbringing. In the end we will get even worse person then in the previos life (some street thug) who will accumulate more bad karma and so on. How do a man break out of this vicious circle of karma?
Bad actions are inherently stressful and there is a natural tendency to want that which is not stressful and avoid that which is stressful. In example a person far and down could happen to see an englightened being and that could have a powerful positive effect on his mind or other mundane things like acts of kindness or giving, there is just a tendency to seek those things out once one gets a taste for the fruits of moral behavior, the higher the contrast the more obvious it becomes as a fool gets filled with evil he will suffer the consequences. It is like pissing at the wind, eventually one will just figure it out more or less even if by chance one will turn around a bit and discern it is as better. If discernment is not cultivated to a certain point it can deteriorate if one trains what one should not train, does not train what one should train and associates with wrong view.
It's the "it should stop on me" thought. The "I won't pass this BS or hatred along" thought. And the "they are doing it out of weakness" thought.
When we feel wronged, offended, victimized, we always have choice: to take this as the way of the world and accept as our own model of behavior ("everyone is like that, so I must be like that too") or you can decide to stand against it, and hold to your values despite the cruel world.
If we are born to the world of war, we think we must prepare for war to defend ourselves, and that's how we perpetuate war. If we are born to the world of greed/competition we think we must prepare for competition to defend ourselves, and that's how we perpetuate it. If we are born to the world of hypocrisy and wearing masks, we think we can't be authentic and must wear mask, because everyone is like that, and so we perpetuate it. If we are conned we think we must conn. If we are heartbroken we think we must heartbreak.
But if we decide to go with what we think is right, despite the pressure of the circumstances, then we get a chance to break the vicious cycle of karma and change the world.
Karma has contact of 6 sense gates (passa) as a stage , foundation, opportunity, causal (nidana) to play it out causing pains/pleasures/ and everything in between. Without passa, karma is useless. This is from 6 things one should know about karma. How to remove passa (contacting via 6 sense gates) is another question.
Have you seen Lotus buds come out of the mud and blossom into beautiful flowers? Just because you are born into a bad family background, you are not destined to become a bad person. Those who are born into good family backgrounds also become bad persons. ex: Prince Ajatasattu the son of the enlightened king Bimbisara. Future is not written on stone and not always shaped by past actions. The decisions you make here and now play a big role in what is going to come to pass.
Anyways, if you are a bad person in this life, it is highly unlikely that you will be born as a human next time. Once you go below human, it's hard to come back up as you lack intelligence to make wholesome decisions. In that case, one would usually keep going down until one's significant bad Karma is exhausted and a good Karma from the past gets a chance to give results.