Como faço pra parar uma thread?
public void run() {
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setVisible(false);
while (true) {
detectarBola();
if (bi != null) {
ImageIcon ii = new ImageIcon(bi);
jlbImage.setIcon(ii);
}
try {
thread.sleep(50);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
}
}
}
private void detectarBola() {
try {
bi = ImageTV.readImage();
if (bi != null) {
BufferedImage biTemp = bi;
bi = Function.copyImage(biTemp);
dsj.setVisible(false);
this.setVisible(true);
this.setLocation(400,400);
func.setBi(bi);
}else
this.setVisible(false);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
}
}
O programa abre um vídeo.
Fica rodando até maria chegar da lenha, eu tento fechar o formulário, mas não fecha.
Alguém consegue me entender?