Dúvida Thread..como saber que ela finalizou?

Opa :smiley:

Tenho uma classe que implementa Runnable e eu chamo da seguinte maneira:

public class TesteHelper implements Runnable {

	private ContextBase contextBase;
	private String ejbName;
	
	public void run() {
		try {
			executeCommand(ejbName, contextBase);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
	public void setContextBase(ContextBase contextBase) {
		this.contextBase= contextBase;
	}

	public void setEjbName(String ejbName) {
		this.ejbName = ejbName;
	}

	public void goGo(){
		Thread thread = new Thread(this);
		thread.start();
	}
	
	protected ContextBase executeCommand(String ejbName,
			ContextBase contextBase) throws Exception {
		RemoteCommandProxy remoteCommandProxy = new RemoteCommandProxy();
		remoteCommandProxy.setEjbName(ejbName);
		remoteCommandProxy.ejbLookup();
		remoteCommandProxy.execute(contextBase);

		return contextBase;
	}

Delegate

	public String teste() throws Exception {
		ContextBase contextBase = new ContextBase();
		ControlMBean controlMBean = (ControlMBean) getSessionMap()
				.get("controlMBean");
		CargaVO cargaVO = controlMBean.getCargaVO();
		cargaVO.setTpCarga(new Integer(
				Constants.TP_CARGA));
		contextBase.put(Constants.VO_CARGA,
				cargaVO);
		contextBaseRaia
				.put(Constants.LISTA_CARGA,
						controladosMBean.getListaRegistrosProdutos());
		contextBase.put(Constants.VO_CARGA,
				controlMBean.getCargaVO());
		TesteHelper testeHelper = new TesteHelper();
		testeHelper.setContextBaseRaia(contextBase);
		testeHelper.setEjbName("Lanca");
		testeHelper.goGo();
		
		return "exibirPaginaConsulta";
	}

Tem alguma maneira de eu saber quando terminou a execução do método testeHelper.goGo();?

Obg

O método Thread.join espera uma thread terminar.
O método Thread.isAlive indica se a thread ainda está viva.
Veja a documentação:
http://java.sun.com/javase/6/docs/api/java/lang/Thread.html

Use thread.isAlive() para verificar se a thread não terminou.

Ou utilize thread.getState() para verificar o estado atual da thread.

Mas o método precisa continuar sem parar…vou dar uma lida na documentação e qlqr dúvida, eu venho gritar aqui :smiley:

Obrigado