PRIMARY: To evaluate the effectiveness and safety of thalidomide for treatment of oral and esophageal aphthous ulcers (those unrelated to a known infection or malignancy) in patients with advanced HIV disease. To evaluate the effect of thalidomide on HIV load in this patient population. Per 06/28/94 amendment, to evaluate the effectiveness of thalidomide in preventing recurrences in patients whose aphthae completely heal at the end of acute treatment.