If good fences make good neighbors, then the world is experiencing an unprecedented outbreak of neighborliness. They used to wall cities. Now they wall whole countries. The latest country to start building a wall - sorry, a "security fence" - is Thailand, which has just announced plans to build a physical barrier along the most inaccessible 75 km. of its frontier with Malaysia. The goal, says Bangkok, is to stop "terrorists" from crossing into Thailand's restive Muslim-majority southern provinces from northern Malaysia, whose people share the same language and religion. If experience elsewhere is any guide, the whole border will be walled sooner or later. India is well on the way to being walled (except along the Himalayas, where the mountains do the job for free). The barrier along its 3,000-km. border with Pakistan is largely complete except in the parts of Kashmir where the steep and broken terrain precludes the construction of the usual two-row, three-metre-high fence, with concertina wire and mines between the two fences. And India is now building an even longer barrier (3,300 km.) to halt illegal immigration from Bangladesh. While India's walls keep unwelcome intruders out, the barriers around North Korea are meant to keep North Koreans in. The original fortifications along the Demilitarized Zone between North and South Korea, which have been continually improved since the 1950s, were built mainly to stop infiltration by North Korean troops or saboteurs. However, the fence that Beijing is now building along its own frontier with North Korea is a precautionary measure to stop an immense wave of refugees from entering China if the regime in Pyongyang collapses. THE MAJORITY of the new walls springing up around the world are there to stop either terrorist attacks or illegal immigration, but sometimes they also serve as a unilateral way of defining a country's desired borders. That is certainly true of the 2,700 km. of high sand or stone berms, backed by wire fences, mines, radar, troop bunkers and artillery bases, that seal off Western Sahara, annexed by Morocco in 1975, from the camps in Algeria from which many of the former inhabitants waged a guerrilla war until the 1991 cease-fire. It is equally true of the wall that Israel is building through the occupied West Bank. The country has long had heavily mined and monitored barrier fences along its external frontiers with Egypt, Jordan, Syria and Lebanon and around the Gaza Strip, but the wall in the West Bank does not follow the cease-fire line of 1967. Instead it penetrates deep into the Palestinian territories at a number of points to leave Jewish settlement blocs on the Israeli side, and it cuts off (Arab) east Jerusalem from the West Bank entirely. Pakistan is building a 2,400-km. fence with Afghanistan, Uzbekistan has built a fence along its border with Tajikistan, the United Arab Emirates is erecting a barrier along its frontier with Oman, and Kuwait is upgrading its existing 215-km. wall along the Iraqi frontier. But the most impressive barriers are certainly around Saudi Arabia. The Saudi kingdom has been quietly pursuing an $8.5 billion project to fence off the full length of its porous border with Yemen for some years, but the highest priority now is to get a high-tech barrier built along the 900-km. border with Iraq. "If and when Iraq fragments, there's going to be a lot of people heading south," said Nawaf Obaid, head of the Saudi National Security Assessment Project, "and that is when we have to be prepared." The new wall will include buried movement sensors, ultraviolet night-vision cameras, face-recognition software and quite probably automated weapons in addition to the usual electrified fences, concertina wire, dry moats and mines. By comparison, the apparently endless debate about building a relatively low-tech fence along the 3,360-km. US border with Mexico to cut illegal immigration seems like an echo from an innocent past. The European Union's feeble gestures toward curbing illegal immigration from Africa (fences around the Spanish enclaves of Ceuta and Melilla on the Moroccan coast, naval patrols off the Canary Islands) seem merely pathetic. But these are probably the last of the Good Old Days, at least in Europe. The reason that the United States is incapable of controlling its Mexican border is political, not financial or technological: powerful domestic lobbies work to ensure a steady supply of "undocumented" Mexican workers who will accept very low wages because they are in the US illegally. President George W. Bush has now been authorized by Congress to build a fence along about 1,125 km. of the Mexican border, but he will stall as long as he can while experimenting with a so-called "virtual fence." No equivalent lobby operates in the EU, and it is only a matter of time before really serious barriers appear on the EU's land frontiers, especially with Russia, Belarus, Ukraine and Turkey. The walls are going up all over the world, and most of them will not come down for a long time, if ever. The writer is a London-based independent journalist whose articles are published in 45 countries.