Oi,
Imaginem a seguinte thread:
private final Thread ThreadListen() {
return (new Thread(new Runnable() {
public void run() {
while (!io_th_listen.isInterrupted()) {
byte[] lo_receive = io_sk.Receive(); // Socket, ficará aqui até receber algo.
}
}
}));
}
io_th_listen = ThreadListen();
// Tests if this thread is alive ...
if (!io_th_listen.isAlive()) {
// Causes this thread to begin execution.
io_th_listen.start();
}
Até então tudo bem, o programa se desenvolve perfeitamente.
Agora, imaginem essa outra situação:
for (int i = 0; i < 3; i++) {
io_th_listen = ThreadListen();
// Tests if this thread is alive ...
if (!io_th_listen.isAlive()) {
// Causes this thread to begin execution.
io_th_listen.start();
}
}
O que irá acontecer?
Tchauzin!