[Question] How to stay concentrated for a long period of time?

I find it nearly impossible to focus on anything more than 2+ hours straight. Even if I enjoy an activity, I end up being distracted by a hell lot of things or just being too exhausted to continue doing it.

The situation is only getting worse if I have a task that is not rewarding in a short-term. Yet a lot of people I know can endure unpleasant tasks even for a few days (e.g. when they have to finish “that dull project” right before deadline).

The question is, how can a person develop ability for staying focused? What kind of tricks can be used? If these tricks can be harmful for health, I’d like to hear about them anyway.