pls see a child therapist/counselor and along wit ur kid pls ask from her/him tips on how to manage the situation when it arises.
it looks like he feels that the solution to any attention is beating, shouting etc.
unwittingly perhaps u or ur family have taught him this or he may have learnt it from the tv, cartoons, video games etc. children can only learn thru example and what's acceptable at home. so right now behavioral therapy is what he needs to go thru.
Read more