In a comparative task, you need to define the terms of the question. So here you need to consider what is meant by a 'hero'. Is it the character who is central to the plot of the novel? Does it imply a judgment on their goodness? Does it suggest someone conventionally handsome - a romantic hero?
Gabriel first proposes to Bathsheba early in the novel. He is disarmingly frank in his courtship, and genuinely attracted to Bathsheba, though taken aback by her behaviour, which seems to encourage and then reject him. He then spends much of the novel observing, assisting, and occasionally reprimanding Bathsheba from his new position as lowly shepherd on Bathsheba's estate. His quiet yet unswerving honesty, his practicality and patience, win him the heroine in the end. He is a capable, virtuous hero, not without passion.
Troy is in the mould of the dashing, unscrupulous hero of romantic fiction. He woos Bathsheba with arrogant assurance in his own personal magnetism. The scene with the sword fight is rife with sexual tension. But his abandonment of Bathsheba, his profligacy and degenerate nature, make it hard to see him as the hero. In the end, it is the resurgence of his feelings for Fanny, too late to save her, that makes us respond to him with a degree of pathos.
Boldwood is the older, powerful bachelor, distant and remote until changed forever by the thoughtless action of Bathsheba's valentine. He becomes a tragic figure, though not, I'd say, the hero.