There are indeed better ways of showing your strength as a party leader. Thatcher may not have been popular among everyone, to say the least I think she made a lot of mistakes such as not managing the failing primary industry in the North of England and not making more efforts to re train former stafff and thinking Poll tax was a good idea, but one thing she did do well is show strength, in that she sacked a lot of ministers who didn't agree with her views instead of having them stay and cause problems later this made her very unpopular among the backbenchers in the Conservative party. Cameron's aim with this referendum is that he aimed to reassure the anti EU Conservative MPs that it was a good idea to stay, this did not work at all and he is as good as resigned. Another thing is encourage leadership contests, this means that when another potential leader wants to challenge for party leader than it means that the squabbles remain inside the Conservative party and don't spread outside and bring the whole country down with it.
To conclude the EU referendum was the perhaps the worst thing that Cameron could have done to show his strength when there were smarter and less damaging ways in which he could have, At the very end it is best said he was a career politician nothing more nothing less who was more reactive rather than pro active which is what is necessary in turbulent times such as these.