A medical procedure involving internal examination, biopsy, and/or resection of disease or masses within the pleural cavity, (the thin fluid-filled space between the two lungs), and thoracic cavity (or chest cavity). Thoracoscopy uses an endoscope primarily to visually examine the pleura, lungs, and mediastinum and to obtain tissue for testing purposes.