Holding a stretch is not necessary to get the benefit. A stretch that is held is also known as a static stretch. There is no harm in stretching this way as long as there is no pain.
Stretching before exercise is not necessarily beneficial. Performing static stretches before exercise may worsen performance when doing activities like sprinting. Holding static stretches tire out your muscles. Instead warming up with dynamic stretches are recommended. Dynamic stretches are like an extension of the workout but at a lower intensity. A recommended warm-up may be a brisk walk, walking lunges, leg swings, and high steps.
Stretching after exercise is an optimal time to stretch. After exercise, individuals are more flexible due to the increased circulation to muscles and joints. This is the best time to engage in static stretches as individuals will get the most benefit from them.
It is just important to stretch at some point in time, this can be when getting out of bed or during breaks at work. Stretching should be a part of a regular routine.