Youths on state farms just outside Shanghai have gone on strike and in a few cases committed suicide to protest new, strict measures to handle China's massive urban over-population and unemployment, Chinese and foreign residents here say.

The residents report that peasants had to be hired to harvest crops last fall at some state farms. Youths assigned there from the city refused to come out of their dormitories when told they no longer would be rotated back to city jobs after two or three years of farm labor.

"They just sat there and listened to the "Voice of America," said one foreign resident of Shanghai who has spoken to some of the youths, devotees of Western music. Residents here say they have been told work slowdowns or strikes by some state farm youths are continuing.

The protests, which Chinese youths insisted involved some suicides, marked a period of great flux in China's effort to control its urban population. For years, China has depended on a program sending most city middle or high school graduates to the countryside for at least two or three years. But the government has allowed so many exceptions to that policy since the death of its principal advocate, the late Communist Party chairman Mao Tse-tung, that it seems to have been virtually abandoned in many places.

For several weeks in early 1979, youths returning to Shanghai from the country to spend Chinese New Year with their families extended their stay to demonstrate, vandalize and loot shops and eventually tie up trains departing Shanghai's railway station for several hours Feb. 5.

Chinese and foreign residents here say the government has jailed a few of the leading troublemakers -- prison sentences for three of them were announced in the official press -- and put heavy pressure on the others to return to their farm jobs in remote rural areas. Many have left town, at least temporarily, the residents said. "Their neighbors, even the parents, were encouraged to talk to them and I persuade them to go back," one Chinese student said. "Police would make several vists to the home. They couldn't get food ration tickets without jobs in the city." Many other youths here have managed to arrange at least temporary city assignments, often in the new neighborhood cooperatives that do repair and cleanup work throughout the city. Intervention of parents with city officials and bribes to officials back in rural units often have helped facilitate their return to Shanghai, residents here said. One youth who led a small demonstration here at the visit last year of the Boston Symphony Orchestra was reported by a friend to have returned reluctantly to the commune in Heilongjiang in the far northeast, where he has worked for a decade. He wrote to the friend to say, however, that he still hoped to return to Shanghai, even though as an orphan with only a brother in the city he lacked the parental connections that could help his case.

Shanghai has approximately 10 million people in the city and incorporated suburbs, making it China's and by most estimates the world's most populous city. It provides its working residents with guaranteed grain and other food supplies, access to large department stores and a range of movie theaters, parks and bookstores not ususally found in rural China. Children raised in the city have more and better middle schools, and thus a better chance of passing the now all-important college entrance examination.

There are still very few university places, however, and youths accustomed to the city's comforts and unable to get factory jobs find themselves faced with years, perhaps a lifetime, of work in the countryside. About 10 to 20 million of China's urban population of 200 million are thought to be unemployed or severely underemployed youth. Many of those are in this magnet city.

The government has tried to soothe their parents, whose support is necessary for continued political stability, by trying to arrange more factory jobs and setting up the neighborhood cooperatives. Residents here say buildings are looking cleaner and better maintained because of the young cooperative members, who are contracted to work for local companies. It is unclear how long they will be content with wages that are usually about half the average here.

The government also has tried to mollify the youths by sending them to rural communities close to their home cities, allowing more frequent visits. Many of the Shanghai youths now working in nearby state farms appear to have benefited from this program but they expected that the party would follow a practice of assigning them city jobs after two or three years. A recent announcement canceling this understanding led to the strikes, residents here said.

There have been other strikes reported by youths at rural communes and farms in other provinces over the past year. A major strike by youths in Yunnan Province reportedly resulted in several wallposters in Peking a year ago. There has been no word how it has been resolved.

Peasant leaders, when asked by foreign visitors what they thought of city youths assigned to their units, have made little secret of their distaste for the program and appear relieved that many youths have been allowed to move back to the city.

Peking reportedly demanded tough action against the Feb. 5 youth rioters who stopped all railroad traffic. Earlier, gangs had gone up and down. Nanking road, occasionally stopping to harass passers-by and looting shops. Residents blamed much of the voilence on local young criminals mixed in with the young people from the countryside, but said the incidents hurt the sympathy the general population had for the plight of the youths.

A former vice minister of public security, Yan Youmin, serves as a vice mayor here now, and recently there have been few of the wallposters on public expressions of dissent seen in Peking. One resident says, "people in Shanghai are too sophisticated for that." But there was a sit-down strike by petitioners at a government office here late last year and some authors and playwrights are working out their feelings in some unusually frank and sarcastic short stories and plays appearing here recently.