For generations, the world's cities have struggled to keep themselves safe.

"Wall Street Explosion Kills 30; Injures 300," The New York Times' front page proclaimed after a bomb ripped through New York City's financial district. "Red Plot Seen in Blast."

It was September 1920. The bomb was carried by a horse-drawn cart. The bombers, suspected to be Italian anarchists, were never caught.

There are times today when it can seem that back in some hazy bygone era — before a Monday evening bomb tore through a Bangkok temple, or train bombers terrorized Madrid in 2004, before two jetliners slammed into the World Trade Center on a clear September morning — the world was not so dangerous.

And in some ways the world is more deadly. Global networks of extremists can now launch attacks from Kenya to Iraq to suburban Washington, D.C., while modernity's worst-case scenarios — nuclear or biological attacks, for example — can make that carriage-pulled Wall Street bomb seem like a toy.

And yet: "We live in a much safer world now," said Ajai Sahni, a longtime New Delhi-based scholar of political violence, policing and security issues. "The world was far more dangerous in a time when war was an accepted method of intervention" and when angering a local political boss could mean "your head would be on a stick."

In Bangkok this week, that comparison was little comfort. The city of about 10 million is struggling in the aftermath of an unexplained bombing Monday that killed 20 people and injured more than 120, and was further shaken the next day by a second blast that caused no casualties but police say may be related.

"We have always been so peaceful," said Chondej Chaiyanun, a 33-year-old Bangkok furniture importer. He said the first blast had concerned him, but it was the second explosion that "made me feel like Bangkok might not be so safe."

Once, there was a simple way for cities to thwart lone attackers, and those operating in small groups. Thick walls, from New Delhi to Florence, allowed guards to monitor access to cities and filter out some dangers.

Today, the fluidity of the modern world makes monitoring a city desperately complicated. Hundreds of thousands of commuters flood into major cities every day; the population of some American cities more than doubles on a work day. Then there is tourism: Thailand welcomed nearly 25 million tourists last year, and Jerusalem, a city of 800,000, can see over 3.5 million travelers annually.

At the same time, it has become easier for attacks to draw the attention violent extremists crave. A couple decades ago, most of the world would have seen the Bangkok bombing reduced to just a few newspaper paragraphs, but today, news of violence jumps quickly and fiercely across continents. Photos and video from the bombing began spilling onto social media almost immediately after it occurred.

So how do you protect a city where so many people — so many potential dangers — are coming and going?

It has become an eternal question in Jerusalem, and deeply relevant after a series of attacks over the past year. A series of barriers, from tall concrete walls to strings of barbed wire, along with a sophisticated Israeli intelligence apparatus and security coordination with Palestinian authorities, have helped stem years of carefully planned and highly deadly suicide bombings, Israeli officials say.

But walls can do little against the wave of lone-wolf attacks that have swept the country as Palestinians, often with no known militant affiliation, attack Israelis with guns or knives or by driving vehicles into crowds.

In Jerusalem's Old City, a frequent flashpoint for violence, police now use hundreds of security cameras that are monitored around the clock to respond quickly to any trouble.

"This really increases the feeling of security for people," said Israeli police spokeswoman Luba Samri. Police patrols are also often highly visible, especially at times of heightened tensions.

Thai officials say the Bangkok bomber was no lone wolf. While offering no details, national police chief Somyot Poompanmoung said the bomber "didn't do it alone, for sure. ... they work as a network, know how to escape. No one person can do this."

Prayuth Chan-ocha, the head of Thailand's military junta, called the bombing "the worst incident that has ever happened in Thailand," and vowed to track down the perpetrators.

It's unclear whether authorities are close to arrests, and their statements have sometimes been contradictory. A military spokesman said Thursday that investigators believe the attack wasn't the work of international terrorists — a day after police issued an arrest warrant that described the still-unidentified prime suspect as a "foreign man."

The bombing struck a city that had already been desperate for stability. The Thai military seized power in May 2014 following months of political protests, with the goal of bringing unity. But the country remains sharply divided along social and political lines, a schism that pits the rural poor against the traditional elite.

Chondej, the furniture importer, has more confidence in the junta than in the police, widely derided in Thailand for corruption.

"I think the military can take care of the (security) situation," he said. "We don't have that much confidence in the efficiency of the police."

To Sahni, good policing is a key component to keeping cities safe.

"The attack, per se, is not the point at which you can build permanent defenses," he said.

"Any terror attack has a long series of precedents, some very minor, that led up to it. There's the recruitment, the conspiracy, the transport of materials," he said. "There are the phases where you have a far better method to intervene."

He sees the answer in everything from sophisticated intelligence networks that can infiltrate suspect groups, to neighborhood watch organizations to restrictions on purchasing chemicals that can be used in explosives.

But even if that works perfectly, he said, it won't stop every attack: "At the end of the day there is no guarantee."

___

Associated Press writers Nattasuda Anusonadisai in Bangkok and Josef Federman in Jerusalem contributed to this story.