RICE. You should start with rice as a home treatment. After 48-72 hours you may switch to heat (instead of ice). As your pain starts to subside you may add stretching as tolerated, and massage. Once pain is gone, then gently return to activity as your strength and flexibility may need time to recovery after the injury. Depending on the severity you may need the supervision if a physical therapist!
Ice injured muscles. Tight or cramping of muscle-tendon units such as the hamstrings that cross both the hip and knee joints prevent normal bending forward at the waist with the knees straight. The tightness can cause discomfort but should not be painful. An actual hamstring tear causes significant pain performing any stretching maneuver and warrants seeking medical attention for treatment.