Is there anything wrong with this code? No object refers to KKMultiServerThread after it is created. Will it be removed by garbage collector?

std (std)
import java.net.*;
import java.io.*;

public class KKMultiServer {
public static void main(String[] args) throws IOException {
ServerSocket serverSocket = null;
boolean listening = true;

try {
serverSocket = new ServerSocket(4444);
} catch (IOException e) {
System.err.println("Could not listen on port: 4444.");
System.exit(-1);
}

while (listening)
new KKMultiServerThread(serverSocket.accept()).start();

serverSocket.close();
}
}
(#204419@0)
2001-9-18 -05:00

回到话题: Is there anything wrong with this code? No object refers to KKMultiServerThread after it is created. Will it be removed by garbage collector?

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论

URL:   
http://www.rolia.net/zh/post.php?f=0&p=204419