import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class MyServer {
//定义保存所有Socket的ArrayList,并将其包装为线程安全
public static List<Socket> socketList = Collections.synchronizedList(new ArrayList<>());
public static void main(String[] args)throws IOException{
ServerSocket ss=new ServerSocket(3000);
while(true){
Socket s=ss.accept();
socketList.add(s);
new Thread(new ServerThread(s)).start();
}
}
}
Why I run the program,the Console shows that"Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at com.eyck.inet.MyServer.main(MyServer.java:14)"
the error seems in line 9.