U.N. High Commissioner for Refugees Poul Hartling said today that a 3 1/2-year-old program to allow Vietnamese refugees to leave their country legally had become "a success story" and was helping to alleviate the problem of Vietnam's "boat people."

"I think we are coming closer to the end of the problem," Hartling told a news conference here shortly before leaving Thailand for a four-day visit to Vietnam. "But I have no forecast as to how many months or years it will still go on." Hartling also said he would probably discuss with Vietnamese officials a recent U.S. proposal to take in as refugees thousands of political prisoners held in Vietnamese reeducation camps.

"It would be natural that we talk about it," Hartling said. But he said he was not taking any message to Hanoi on the subject.

A Vietnamese Embassy spokesman here said that "more than 10,000" inmates remain in reeducation camps, which were established after the communist takeover of South Vietnam in April 1975 to detain government and military personnel loyal to the defeated Saigon administration.

The spokesman said Hanoi's repeated offer to send the inmates to the United States meant accepting all or none. But he indicated that this could be a subject of negotiation. U.S. officials previously have interpreted the Vietnamese offer as an effort to put the ball in the American court in response to criticism of the reeducation camps on human rights grounds.

Citing refugee reports, the officials have said the camps include common criminals as well as political prisoners, which could pose a problem for eventual negotiations.

In his news conference, Hartling said a main topic of discussions in Vietnam would be the Orderly Departure Program, a U.N.-sponsored arrangement to process Vietnamese for emigration and send them out by plane to Thailand for resettlement elsewhere.

Currently, about 2,500 of these Vietnamese "plane people" are leaving each month under the program, refugee officials said. "This number is roughly equal to the total monthly arrivals in the region by boat people," Hartling said.

According to the latest U.N. figures, 2,636 people left Vietnam under the program in July, compared to 2,048 arrivals of Vietnamese boat people in the region that month.

A U.S. refugee official said the number of orderly departures in the fiscal year ending in October was expected to reach 28,000, compared to less than 12,500 in fiscal 1982. Nearly half of these plane people fly on to the United States after brief stopovers in Thailand. Most of the rest are taken in by Australia, Canada, France and West Germany.

"The Orderly Departure Program has been a success story," Hartling said. "There are still problems, but it's working."

One of the problems is that the program is accessible primarily to city dwellers in southern Vietnam, but rarely to people in rural areas. Refugee officials say many of the boat people now are farmers and fishermen.

Others are those too impatient or desperate to wait the months or years it may take to go through the program, Vietnamese who cannot or will not deal with the Communist authorities to get into the program, or those who do not qualify for acceptance by the western resettlement countries.

According to refugee officials, many of the Vietnamese leaving under the program are from the middle class, and some have received higher education abroad. The officials say Vietnam thus has lost a number of doctors, engineers, teachers and at least one nuclear physicist.

Hartling, a former Danish prime minister and foreign minister, arrived here Sept. 4 to discuss the refugee situation with Thai officials, whose country has received about 600,000 of the more than 1 million Indochinese who have fled their homelands since the communist takeovers of Cambodia, South Vietnam and Laos in 1975.

Most of those refugees have been resettled abroad, but 125,000 remain in Thai camps. Since 1975, the U.N. commissioner has spent nearly $300 million here on assistance programs for Indochinese refugees, Hartling said.

In their meetings with Hartling, Thai officials have expressed concern about the slower pace of refugee resettlement this year. They have urged him to persuade western countries to speed processing of those who have failed to qualify for resettlement. A major Thai fear is that the country will be stuck with thousands of Indochinese refugess that no western countries want.

Vietnamese refugees account for 9,000 of the 125,000 Indochinese refugees still living in Thai camps. The rest are Laotians and Cambodians who have crossed those countries' borders into neighboring Thailand.

The head of Thailand's National Security Council, Prasong Soonsiri, also told Hartling of a proposal to close the sprawling Khao-i-Dang refugee camp inhabited by about 40,000 Cambodian refugees near the Thai-Cambodian border.

Prasong said that those refugees not accepted for resettlement abroad should then be sent across the border to camps controlled by Cambodian resistance factions battling the Vietnamese occupation of their country.

Hartling said that he had insisted that any such repatriation be strictly voluntary, and that Prasong had agreed to this. "I got reassurances from the Thai government that they will work closely with us and will not force people out against their will," Hartling said.

Thai authorities have said they want to close the Khao-i-Dang camp by sometime early next year.

Despite the figures showing more orderly departures from Vietnam than regional arrivals of boat people lately, some refugee officials warn that the situation in Vietnam remains precarious and that the refugee floodgates could open again if circumstances change.

Besides the Orderly Departure Program, they said, a number of factors have contributed to the decrease in boat people. Among them are a shortage of available boats, stricter Vietnamese controls on engines and gasoline, tighter security to prevent illegal departures, the risk of pirate attacks and awareness of greater difficulty in obtaining resettlement abroad, the officials said.

In addition, the number of Vietnamese who leave by boat but never reach their destinations remains unknown, but may be quite high. "People who come out tell us they believe half of those who go by boat will die," a U.S. refugee official said.

One development that could multiply the number of boat people, as in 1979 and 1980, would be a Vietnamese decision to curtail the Orderly Departure Program, refugee officials said. They said that at least two-thirds of those who leave Vietnam under the program say they had already tried to leave by boat or had considered it.

Although refugee officials say the most desperate Vietnamese probably have already left in one way or another, it is widely agreed that many more still want to go.

According to Donald Colin, who heads the U.S. end of the Orderly Departure Program here, U.S. files contain 114,148 "active cases" of Vietnamese applicants for emigration to the United States, totaling 490,450 people. He estimates that "probably another half a million are in the files of other receiving countries."

While the program evidently suits Hanoi's purposes for now, some refugee officials believe the Vietnamese eventually will have to terminate it. For Hartling, a main concern of his trip to Thailand and Vietnam is to keep the program operating and continue to provide a safe alternative to the hazardous journey from Vietnam in often ill-equipped, rickety fishing boats.

"At some point they might try an East German solution," said a U.S. official, referring to the 1961 effort to contain potential refugees that resulted in the Berlin Wall. "But that would take an awful lot of bricks."