Young people abandoning farm jobs have rioted in Shanghai, blocking trains and traffic and looting shops in the most serious recent manifestation of a social dilemma threatening China's modernization program.

An official Shanghai newspaper, the Liberation Daily, reported that at least 1,000 youths blocked a major intersection of China's largest city earlier this week and surrounded an employment office to press their demands for city jobs instead of backbreaking farm work.

An estimated 10 million urban Chinese in their 20s and early 30s work in jobs in the countryside despite middle school and college educations that might entitle them to office assignments. The government in the last few years has attempted to take many of these youths off the farms, reducing the number in the countryside from a peak of about 16 million in the early 1970s. But government promises to eventually end the farm assignments have apparently created widespread hopes for more city jobs at a time when Chinese industrial and urban development is far from a point where it can provide them.

"We cannot now solve all the problems at once encountered by educated youth," another Shanghai newspaper said recently. "Nor can we immediately make proper arrangements for those educated youth who have been allowed to return to Shanghai from the countryside. Problems may be solved quickly or not so quickly."

Resentment among youth at delays in returning them to city assignments is expected to spread to their parents, who in Shanghai and other Chinese cities include the technicians and scientists needed to lead the modernization of the economy. Government promises of a better deal for educated youth seem designed in part to win support for the new Chinese leadership from these urban parents. Many may now wonder if the government has carefully thought out the many other social and economic changes it has announced in recent months.

The official People's Daily reflected this impatience on the part of many Chinese in an editorial today that warned against "anarchy." It advised people to work hard and not expect their lives to improve quickly.

"Thousands of things have been shattered and there are hundreds of things to do," the editorial said. "All the problems cannot be solved in one day."

The Liberatin Daily said the demonstrating youth, "in a vain attempt to achieve personal goals, violated social orders. They blocked the streets with large crowds and tried to stop trains."

The newspaper printed complaints from many city residents, who alleged some shops had been looted and an electrical store was occupied for more than hour in an attempt to force the manager to donate electric bullhorns, useful for organizing future demonstrations.

Some people charge that some of the youths had been assigned to relatively good, non-farm jobs in other parts of China and were just looking for an excuse to stay in Shanghai, China's most cosmopolitan city.

The Shanghai report said several hundred youths blocked the exits of the Shanghai municipal employment bureau and did not let the staff leave. Some youths barged in to demand changes in the job assignment system, according to one Shanghai resident.

In Shanghai, the enormous social problem of educated youth appears to have merged with the campaign for more democracy in China in a series of demonstrations and wallposters that had been peaceful up to new. The only other recent report of violence, related by diplomatic sources, concerned a woman allegedly shot in the hip by police during a worker demonstration.

Educated city youth first began to receive rural assignments in great numbers in the 1960s where the government sought to control urban population, help youths appreciate rural problems and dampen the political activities of the Red Guards. Also the Chinese education system had expanded beyond the point where urban offices could absorb all graduates.

Many Chinese blamed the late chairman Mao Tse-tung for the "send to the countryside" program. They rejoiced when Mao's successors announced a program of rapid modernization that seemed to call for better use of people with middle school and college educations.

Incidents in recent months have shown dissatisfaction with the pace of the new program, however. Several young people assigned to Yunnan in the far southwest put up scores of wallposters in Peking in December saying urban youth in that province had staged a strike to protest bad living conditions. A wallposter in the northern city of Sian last month said 30 youths were on a hunger strike there because they were being moved to a rural area far from the provincial capital where they thought they would be reassigned shortly.

For the last two years, thousands of youths have returned to the cities without authorization and have tried to live without wages or ration cards. Many have turned to crime. A Peking wallposter this month said unemployment among such people had forced some young women to turn to prostitution and men to resort to "begging, gambling, theft and speculation."

Recent middle school graduates who pass a new national college entrance examination now escape assignment to farm work. But graduates who have been working in the countryside for several years have found they are illprepared for the exam and have little time to study.

Disgruntled urban youth assigned to rural work have comprised a large portion of those attempting to cross the border into Hong Kong in the last several years. They also appear to have provided many of the recent wallposters demanding human rights, including the right to choose one's work assignment, that have been put up on city walls throughout China.

The wallposter campaign continues to receive official approval. A Canton broadcast Wednesday announced a special rally to honor three young people who had been jailed in 1974 for putting up a famous wallposter calling for "socialist democracy." One of the poster writers denounced at the rally, however, "the fallacies of some people who describe the spirit of people's democracy now surging up in China as demands for Western democracy and who describe us as opponents of the Communist Party."

Several recent official articles suggest that the Chinese government is attempting ot molify educated youth by finding them jobs in the countryside that require less physical labor, even if they cannot be reassigned to big cities, with better educational opportunities, entertainments and food supplies.

The Shanghai newspaper Wen Hui Bao reported last month that many city youth had been "conducting scientific experiments in agriculture, introducing farm machines and developing educational cultural, health, commercial, industrial and sideline untertakings in the countryside."

Visitors to rural communes find many of the guides assigned to show people around are urban educated youth. Such youth also tend to fill jobs in small factories being set up to supply farm tools and other consumer goods for peasants.

The educated youth problem probably affects Shanghai more than any other Chinese city, and may have helped bring a recent change in the administration. Peng Chung, a veteran party administrator thought to be close to Vice Premier Teng Hsaioping, was promoted to mayor from the number three city job. He succeeded the first political commissar of the Chinese navy, who had been serving as mayor since shortly after Mao's death in 1976.