I wanted to load the list on the Thread and then have access to it after the action ends.
It has this code but at the end of the thread the list is null;
Would anyone have a tip to help me?
public class ThreadListarClientes {
private List<Cliente> clientes = null;
ClienteCTR clienteCTR = new ClienteCTR();
private Integer contaid = null;
public ThreadListarClientes carregarThreadListarClientes() throws InterruptedException {
Thread thread = new Thread() {
@Override
public void run() {
clientes = clienteCTR.listar(contaid, "clienteid", false);
}
};
thread.start();
while (thread.getState() != Thread.State.TERMINATED) {
Thread.sleep(100);
}
return this;
}
public List<Cliente> getClientes() {
return clientes;
}
public void setClientes(List<Cliente> clientes) {
this.clientes = clientes;
}
public Integer getContaid() {
return contaid;
}
public void setContaid(Integer contaid) {
this.contaid = contaid;
}
}