The sons of two senior Chinese Communist Party officials in Shanghai were paraded before thousands of spectators and then executed for rape, official reports said today. The executions were part of a campaign to warn the children of high-ranking party officials that they are not above the law.

The two were among three men executed yesterday after a mass rally in a Shanghai gymnasium, according to official reports. The three were part of a gang convicted of six rapes, three attempted rapes and seduction or indecent behavior toward 42 other women between 1981 and 1984, according to official press reports.

The party's leading newspaper, the People's Daily, said in a front-page commentary today that the executions of the three men as well as the imprisonment of three others showed that "all are equal before the law."

The Shanghai case is the first of its kind to come to light in China's largest city since the Communists took power in 1949. It also involves the first death sentences to be handed down since the party began a drive against corruption and "unhealthy tendencies" within the party six weeks ago.

Official press reports indicated that the executions were aimed in part at countering the widespread perception that the country's laws are designed only for ordinary citizens and that Communist Party officials and their relatives are above the law. Complaints from ordinary citizens about the privileges and immunities enjoyed by the children of high-level cadres had apparently reached the point where the party felt compelled to act, according to diplomats.

It is not unusual for Chinese courts to give the death penalty to those convicted of rape. Out of 26 executions announced in Peking last month, 10 involved convictions for rape. What is unusual is for the sons of high-ranking party officials, or "princes," as some observers call them, to be given the death penalty.

The three men executed were Chen Xiaomeng, a reporter for a Shanghai magazine called Democracy and the Legal System; Hu Xiaoyang, a reporter for an architecture magazine, and Ge Zhiwen, a worker in a Shanghai perfume factory. They were described in press reports as "multiple rapists" who once "ran rampant" in Shanghai.

Chen was the son of Chen Qiwu, the late vice chief of the propaganda department of the Communist Party committee of Shanghai. Hu was the son of Hu Lijiao, who is chairman of the Standing Committee of the People's Congress of the city, a former member of the Communist Party Central Committee and a veteran of the famous Long March of 1934-35.

Chen made a 55,000-word confession, according to a Shanghai newspaper.

"I am not handsome," Chen was reported to have written. "But I am the son of a high official and some young women wanted to make contact with me and ask for favors. Then I just took advantage of that to rape or seduce them."

The three men were shown handcuffed on national television tonight as they stood yesterday before uniformed judges at a Shanghai gymnasium filled with thousands of people. The men appeared to be in their late twenties or early thirties. They were apparently executed at another location. The usual method of execution in China is a pistol shot at the back of the neck.

The Shanghai weekly newspaper Society, in a lengthy report published 10 days ago, said the Shanghai rapists were able to lead dissolute lives for three years without being challenged, apparently because two of their parents had held high positions that tended to intimidate anyone desiring to bring them to justice. The newspaper said none of the victims spoke out for fear of retaliation.

When the Shanghai police learned of the rapists' activities, the newspaper said, the police were reluctant to deal with the case because they also feared that pursuing it might bring retaliation from their superiors in the party and government. The newspaper said one of those convicted, journalist Chen, was a conscientious, diligent worker by day and a playboy at night.

The newspaper said Chen's confession revealed that he believed the police would never arrest him because they would have to take into account his late father's high standing. He believed that an ordinary citizen could never win a case against him.

According to the newspaper and reports in other official papers, the gang's way of operating was to bring young women to Chen's home by motorcycle for wild parties that often ended in the bedroom. In some cases, Chen and Hu told the young women that they were the sons of high officials and could help the women obtain job transfers or other favors.

The victims included blue- and white-collar workers, nurses, teachers, actresses and university students, according to a report in Shanghai's official Liberation Daily.