I'm developing a cliente-servidor
application, the server has two threads (a in
and a out
) well implemented.
I run the server (okay), I run the first client and put it as online (okay), I run the second client and when I load it online it gets blocked.
I tried to cycle:
for(int i = 0; i < 2; i++)
I noticed with this cycle that the first client also blocks when going online, that is, the error of my project is here! Can someone help me?
Follow the code:
public PainelEstadoContacto(JanelaUtilizador janelaUtilizador) {
this.janelaUtilizador=janelaUtilizador;
botaoOnline= new JButton("ONLINE");
botaoOnline.addActionListener(e -> {
String nome = nomeUtilizador.getText();
if(!nome.isEmpty()){
this.mensagem = new Mensagem();
this.mensagem.setAccao(Accao.ONLINE);
this.mensagem.setNomeClienteEnviaMensagem(nome);
this.socketCliente = new SocketCliente();
this.socket = this.socketCliente.estabelecerLigacao();
new Thread(new ThreadCliente(this.socket)).start(); }
this.socketCliente.enviar(mensagem);
});