The bomb threat was just a hoax, but officials at Hebron High School near Dallas took no chances: School officials called the police and locked down the school this week. Separately, a middle school 2,000 miles away in Washington State went on lockdown after a student brought a toy gun to class.

But the threat and the gun were real at Berrendo Middle School in Roswell, N.M., where a seventh grader with a sawed-off shotgun walked into the gymnasium and opened fire on his classmates on Tuesday, wounding two of them. School officials and teachers, who had long prepared for such a moment, locked down the school as police officers and parents rushed to the scene.

For students across the country, lockdowns have become a fixture of the school day, the duck-and-cover drills for a generation growing up in the shadow of Columbine High School in Colorado and Sandy Hook Elementary School in Connecticut. Kindergartners learn to hide quietly behind bookshelves. Teachers warn high school students that the glow of their cellphones could make them targets. And parents get regular text messages from school officials alerting them to lockdowns.

School administrators across the country have worked with police departments in recent years to create detailed plans to secure their schools, an effort that was redoubled after the December 2012 shootings in Newtown, Conn. At the whiff of a threat, teachers are now instructed to snap off the lights, lock their doors and usher their students into corners and closets. School officials call the police. Students huddle in their classrooms for minutes or hours, texting one another, playing cards and board games, or just waiting until they get the all clear.