Continued from page 1

“Eighty percent of the permanent residents applauded the practice,” said Guo Ruifeng, deputy director of Laosanyu’s village committee. He didn’t say how many migrants approved, though they outnumber the locals by 7,000 to 700.

“Anyway, they should understand that it is all for their safety,” he said, adding that guards only check papers if they see something suspicious.

Gating has been an easy and effective way to control population throughout Chinese history, said Ms. Huang, the geography professor. In past centuries, some walled cities would impose curfews and close their gates overnight. In the first decades of communist rule, the desire for top-down organization and control showed in work-unit compounds, usually guarded and enclosed.

As the economy has grown, privately run gated communities with their own security have emerged in the biggest cities, catering to well-to-do Chinese and expatriates, offering upscale houses and facilities such as pools and gyms.

The new gated villages in Beijing are very different.

“To put it crudely, gated communities in the city are a way for the upper middle class and urban rich to keep out trespassers, whereas gated villages represent a way for the state to ‘keep in’ or contain the problem of ‘migrant workers’ who live in these villages,” said Pow Choon-Pieu, an assistant professor of geography at the National University of Singapore who has studied the issue, in an e-mail.

Jiang Zhengqing, a supermarket owner in the gated compound of Laosanyu, told the China Daily newspaper in May that he doesn’t even know if he’ll be in business next year because of the drop in customers.

“Before, the streets were crowded with people in the afternoon, but now the village is deserted,” he said. “I can’t understand why the government has invested such a large amount of money into putting up these useless fences rather than repair our dirty public restrooms and bumpy roads.”