TOKYO, JULY 15 -- A Japanese company's illegal sale of advanced technology to the Soviet Union and the angry reaction to it in Washington have rocked Japan's staid corporate world with a force rarely found in the postwar period.

Four top executives have quit and two executives have been arrested. Prime Minister Yasuhiro Nakasone has denounced the exporter, Toshiba Machine Co., for "betrayal," and a revamping of the export-control system is under way.

Yet none of the steps taken seems to have come close to defusing U.S. anger. Japanese officials view the case as unresolved and as one of the most serious threats to the U.S.-Japanese relationship in years, potentially damaging everything from trade to military cooperation.

It was on May 15 that Japanese investigators publicly confirmed what newspapers here had been reporting for days: that Toshiba Machine, a subsidiary of the giant electronics concern Toshiba Corp., had sold advanced computer-controlled machine tools to Moscow in violation of an international agreement restricting high-technology exports to the Soviet bloc.

A Norwegian company, Kongsberg Vaapenfabrik, also was involved, illegally providing advanced computer software to run the machines.

U.S. officials say the Japanese equipment has enabled the Soviets to make submarine propellers that generate much less noise than those produced by conventional equipment, sharply reducing the U.S. Navy's ability to track the Soviet submarine fleet. They say restoring tracking abilities to the previous levels could cost U.S. taxpayers billions of dollars.

Toshiba Machine's president admitted the sale and resigned, and police later arrested two of the company's executives. The Japanese government banned all exports by Toshiba Machine to the Soviet bloc for one year and disciplined two trading companies allegedly involved in the sale. The president of one of the trading houses resigned.

Nonetheless, anger in Washington began to mount quickly. To many American lawmakers, the case confirmed old feelings that the Japanese cynically profit from trade while relying heavily on U.S. taxpayers for military protection.

Early this month, television viewers here were shocked to see American legislators demolishing a Toshiba radio with sledgehammers outside the Capitol. The U.S. Senate, voting 92 to 5, passed a measure that would ban all exports by Toshiba Corp. and Kongsberg Vaapenfabrik to the United States for two to five years.

That vote prompted the resignations of the chairman and president of Toshiba Corp., though they denied that their company knew what its subsidiary was doing. The government, meanwhile, has pressed ahead with a program to tighten export controls.

Newspapers chastised the country's exporters. "If they . . . adopt the position that they will sell to anyone as long as they can make money, they must expect to anger other countries, to be made scapegoats of and to have their products shut out of foreign markets," the nationally circulated Asahi Shimbun said in an editorial.

Many Japanese see U.S. anger as understandable, but feel nonetheless that their country is being singled out for irrational retribution due to general frustration in the United States over the trade deficit with Japan, which totaled almost $60 billion in 1986.

A columnist in the Japan Economic Journal, the leading financial newspaper, noted a widespread view that "the U.S. is overplaying the Toshiba case with the intention to weaken this major high-tech company."

Some Japanese also are questioning whether the evidence is firm that submarines are quieter due to the Toshiba machinery.

"I don't think it's possible that Soviet submarine noise is down solely because they used a milling machine to make the propellers neat and beautiful," said Masanobu Ohtsuka, a spokesman for the Maritime Self-Defense Force, as the Japanese navy is known.

In parliament, opposition lawmakers this week repeatedly pressed Nakasone on this point. They drew the response from him that while Japan has no direct evidence of such a link, the government believes there was one and, in any case, the exporters broke the law.

"A Japanese company has not only damaged national defense," Nakasone told parliament in his strongest statement yet against Toshiba Machine, "but has also committed a crime of betrayal against the Japanese people."

When word reached here of U.S. talk of a ban on Toshiba exports, the Foreign Ministry took the unusual step of saying that it would not try to protect the company. Japanese officials have said, however, that they feel it is unfair to punish Toshiba Corp. for the actions of an independently managed subsidiary.

In general, the tone of the debate has once again underlined that Japan, one of the world's prime economic powers, continues to view itself as a ward of the United States in military matters.

Much of this country's $23 billion-a-year defense budget goes to antisubmarine warfare. Yet hardly anyone has mentioned that Toshiba's sale may have undermined Japan's own forces, which are reported to be having the same difficulties in tracking Soviet submarines as the U.S. Navy is having.

"There is no sense of a security violation in the minds of many people on the streets," said a Japanese official. The only concern, he said, is that the Americans have been angered.

For now, the Japanese have brushed aside as impractical U.S. suggestions that Japan should pay some form of compensation for damaging U.S. security. However, U.S. Defense Secretary Caspar W. Weinberger, after meetings in Tokyo this month, said that the United States and Japan have agreed to step up cooperation in antisubmarine warfare. Officials here say this will consist of research and presumably involve some Japanese money.

Japanese officials have long fought to keep the defense relationship with the United States separate from the economic one. While tempers soared over the trade deficit, military cooperation was better than ever. In January, U.S. and Japanese defense officials meeting in Hawaii even toasted this paradox with champagne.

But this spring the relations began deteriorating, first over a still-unresolved dispute concerning Japan's next-generation fighter jet, known as the FSX. Japan wants to build it largely on its own, while the United States is pressing it to rely heavily on U.S technology.

Now the Toshiba uproar has further soured the mood. In many Japanese officials' eyes, it will make Japanese companies wary of getting involved in research into the Strategic Defense Initiative, the United States' proposed antimissile system. The two countries are expected to sign a formal agreement for such cooperation in Washington next week.

But Japanese corporations fear controversy and public criticism. What if a Japanese SDI contractor were to be accused of leaking findings to the Soviets? One Japanese official said executives here may conclude it is better to stick to conventional business.

The trouble could not have come at a worse time for Toshiba Corp., which -- with sales of nearly $19 billion in the fiscal year ending March 31, 1986 -- ranked as Japan's third-largest electronics producer.

It had already been buffeted by the quick rise of the yen's value and slack exports to the United States and China. In the fiscal year, its profits fell 42.5 percent and it experienced its first drop in sales in 21 years as measured in yen. Losing all U.S. sales would be a tremendous blow.

Toshiba's newly appointed president, Joichi Aoi, told reporters this week that the company still hopes to take part in U.S. defense contracting. "We're determined to make every effort to restore the relationship of trust between Japan and the U.S. that was damaged by this case," he said.