This photo from Tuesday, Nov. 10, 2009 shows New York State Police waiting with families for students to be released after a lockdown at Stissing Mountain Middle School and High School in Pine Plains, N.Y. The president of the National Association of School Resource Officers says schools regularly practice safety plans and have gotten good at taking action anytime they hear about a potential threat in or outside the building.

It’s a familiar scenario: A school official, hearing about a potential danger that’s too close for comfort, locks down the building. A nearby bank may have been robbed. Officers might be serving a warrant in the neighborhood. There are reports of shots fired in the area.

For a northern California elementary school, the quick action is credited with thwarting greater disaster Tuesday when a gunman on a deadly rampage was kept from walking through the school’s doors.

Schools have become adept at rapidly shoring up security, measuring responses against the toll it could take on students’ learning and sense of safety.

On the same day as the California rampage, across the country in upstate New York, a heavily armed gunman fired shots while pacing the parking lot of a dollar store. As police rushed to the scene, two nearby schools issued a “lockout,” with students and teachers going about their regular day while under instructions not to let anyone in the building.

“You want to take appropriate measures but you also don’t want to alarm people unnecessarily, too,” said Matthew Bystrak, acting superintendent of the West Seneca School District outside Buffalo, where the lockouts were issued.

Since the 1999 Columbine High School shooting, active shooter and lockdown drills have become as common as fire drills, with students and staff practicing throughout the year, said Don Bridges, president of the National Association of School Resource Officers.

It’s unknown how frequently the plans are actually implemented in schools in response to perceived dangers in or outside the building.

“Any time schools start to hear about something going on that could possibly pose a threat to their school, there’s got to be some sort of action that the school takes. Even if they don’t go into a full lockdown, there’s a hyper level of awareness,” said Bridges, a school resource officer in Baltimore County, Maryland.

It could mean locking the doors or halting class changes to let paramedics reach an injured student, or a full-blown lockdown in which exterior and interior doors are locked and perhaps barricaded, blinds are drawn, lights turned off and students and teachers crouched out of view.

While students in West Seneca may not have noticed a disruption, it was a different scene in another Buffalo suburb, Alden, two days later when a device with a battery and wires was found in the locker of a student who had talked about making bombs.

The district issued a lockdown, leaping to its highest level of security until sheriff’s deputies with K-9s determined there was no threat, administrators said.

“The disruption is secondary. The safety is primary,” Superintendent Adam Stoltman said Friday. He declined to detail the actions taken inside the high school, saying the district’s safety plan is confidential.

“The end result was it was nothing to be concerned about, but at that time it was very real for people,” said Stoltman, whose district dedicates two weeks of the school year to practice its safety plans.

“If we have a fire emergency, we’ve got that covered,” said Michele Gay, who co-founded Safe and Sound Schools after losing her daughter in the 2012 Sandy Hook Elementary School shooting in Connecticut. “But we’re living in a new age and it’s time to acknowledge that there are other different types of crises and emergencies that we need to be prepared for.”