In the two deadliest shootings in the U.S. this year, the accused gunman had displayed warning signs before his killing spree.

Nikolas Cruz demonstrated an obsession with guns and was the subject of more than a dozen police visits at home before he allegedly went on a February shooting rampage that left 17 dead at his former high school in Parkland, Florida.

Ian David Long, who authorities say burst into the Borderline Bar and Grill in Thousand Oaks, California, late Wednesday night and gunned down 12 people before apparently taking his own life, was found to be “acting a little irrationally’’ when police were summoned to his house in April.

Yet, Cruz and Long were both deemed by officials not to be a danger to themselves or others, and they were neither committed for treatment nor forbidden from possessing weapons.

Amid the grief over yet another mass shooting, there’s also a sense of frustration over the failure to pick up on those cues.

Mental health experts say that, in the absence of expressed credible threats, predicting violent behavior presents a significant challenge.

More:What we know about the mass shooting at a Thousand Oaks, California, dance bar

More:He survived Las Vegas shooting, only to die this week: These are the Thousand Oaks shooting victims

“The ability to identify an individual’s first violent act is extraordinarily difficult – I would say it’s impossible,’’ said Steven Hoge, a forensic psychiatrist and clinical professor at Columbia University. “Because what mental health professionals bring to the table is the ability to identify risks and triggers to past violent acts and to try to figure out how to mitigate or avoid those incidents in the future.’’

Hoge warned against the common perception that the mental health system should identify dangerous people and get them off the streets. Even though they can begin the process of involuntary commitment when they determine someone to be dangerous, he said, the role of mental health professionals is to provide care.

“Psychiatrists exist in this world to treat people for mental illness,’’ he said. “If there are measures that need to be taken because there are concerns about future violence, that’s in the purview of the police.’’

Ventura County Sheriff deputies had mental health specialists evaluate Long when they were called to his house in April. They did not pursue further action.

San Diego-based Clark Clipson, a forensic psychologist since 1991, said making those assessments in the field can be especially difficult.

Clipson usually evaluates persons who have been charged or convicted of a crime, so he has police reports, criminal histories, psychological test results and other data on which to base his conclusions. That information typically is not available in field calls.

“With a threat assessment, where you have maybe an employee or a kid in a school, in those situations you have to have information like, ‘Does the person have a mental disorder? Do they have access to weapons? Do they have thoughts of harming themselves or others?’’’ Clipson said.

“Sometimes you can find those things out by people who know the individual or through social media or things they’ve written or posted, but some people just don’t express those things.’’

One useful tool that has emerged in the wake of the repeated massacres – the Borderline incident marked the 307th time in 311 days this year that someone shot or killed at least four people in the same instance – has been the increased acceptance of so-called red flag laws.

The policy allows family members or law-enforcement agents to seek a court order that temporarily restricts access to guns for the persons in question when they’re considered a danger to themselves or others.

Only five states had such laws in their books before 2018, but eight have adopted them this year – Florida joined the ranks the month – and a total of 29 have considered it.

William Rosen, managing director of state policy and government affairs for the gun-control advocacy group Everytown for Gun Safety, said he expects most of them to enact the legislation in 2019.

“So often we hear that somebody knew the person was a danger to himself or others; the person was making threats online, or posting intimidating content or they were telling people they wanted to be the next school shooter,’’ Rosen said.

“But in the absence of a red flag law, if the person hadn’t committed a crime or come close to it or they were not committable involuntarily due to mental health, there wasn’t really any good tool for law enforcement.’’

The next step after implementation of the law is to establish public-education campaigns to ensure concerned parties know to notify authorities when they observe troubling signs in loved ones, Rosen said.

California has had a red flag law since 2014, but it’s not clear whether Long’s mother, Colleen, who lived with him, ever tried to have it applied to her son, a former Marine machine gunner and combat veteran whom police say may have had post-traumatic stress disorder.

Regardless, Clipson said those laws only go so far and can’t accomplish nearly as much as stricter gun control. Lacking that, the personnel determining who’s truly dangerous have to weigh the possibility of injurious demeanor – which is statistically minute – with each person's civil rights.

Issuing a threat may be an indication, but it’s not enough to take action.

“People say a lot of crazy stuff and if we started locking people up or taking away their guns just because they say crazy things, that would be a problem," Clipson said.