The hamstrings are a group of three muscles at the back of the thigh: the biceps femoris, semitendinosus and semimembranosus. They run down the back of the leg from the hip, then cross the knee. Their primary role is to move the thigh backwards from the hip and to bend the knee. Since these muscles act across two joints, large amounts of force are applied to them during any exercise requiring a high degree of speed, agility and strength. Consequently, injuries to the hamstrings are common occurrences in sports likes sprinting, tennis, basketball and football.
Injuries to the hamstring are divided into three grades. In a Grade I injury, there's some muscle stiffness at the back of the leg, but normal walking and movement are possible. Grade II injuries to the hamstring are usually associated with an audible "pop" caused by the muscle pulling away from the tendon, and it will be very difficult to walk without a limp. Grade III injuries are often characterized by a noticeable lump in the back of the thigh, caused by the muscle rupturing and pulling away from the tendon. Pain is immediate and severe. It's almost impossible to walk without assistance.
Recovery times for a hamstring injury can range from a few days for a Grade I injury, all the way up to 12 weeks for a Grade III, so it's extremely important to know how to lengthen, strengthen and prepare your hamstrings in order to prevent injuries from occurring.
Longer hamstrings are more flexible, so exercises that stretch them are a must. If you are in an office or otherwise stuck in a chair, the hamstrings can be worked by straightening your leg, pointing your toes up and out, then holding that position for as long as you can. If you feel a pull on the back of your knee, you're doing it right. Another effective exercise for the hamstrings is to lay flat on your back, looking up. Reach down behind your right thigh with both hands and slowly pull it into a 90 degree angle relative to the rest of your body. Then, slowly straighten your knee as much as possible. Repeat with the other leg.
One condition that leads to a number of hamstring injuries is when the quadriceps, the large muscle group on the front of the thigh, are overdeveloped in relation to the hamstrings. If you spend a lot of time working on your quads one day, spend an equivalent amount of time exercising the hamstrings the next. Standing and reverse leg curls are excellent for developing hamstrings, as is a step-up exercise using at least a knee-high platform. All of the above will help increase muscle mass in the hamstrings, but if you are specifically targeting increased hamstring mass, then you'll want to try out the Stiff-Legged and Romanian Deadlifts. Both are compound exercises where proper form is very important, not only to build mass, but also to avoid injury. Use light weights until you get the forms down.
Finally, prepare your hamstrings. Stay hydrated. Dehydrated muscles contract, and a contracted hamstring is more apt to tear. Stretch, both before and after exercise. Don't over work them. Muscle fatigue is now thought to be a leading cause of hamstring injuries, and hamstrings that are injured can't be lengthened or strengthened.