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

I find it nearly im­pos­si­ble to fo­cus on any­thing more than 2+ hours straight. Even if I en­joy an ac­tivity, I end up be­ing dis­tracted by a hell lot of things or just be­ing too ex­hausted to con­tinue do­ing it.

The situ­a­tion is only get­ting worse if I have a task that is not re­ward­ing in a short-term. Yet a lot of peo­ple I know can en­dure un­pleas­ant tasks even for a few days (e.g. when they have to finish “that dull pro­ject” right be­fore dead­line).

The ques­tion is, how can a per­son de­velop abil­ity for stay­ing fo­cused? What kind of tricks can be used? If these tricks can be harm­ful for health, I’d like to hear about them any­way.