还可以使用回调方法:
public interface Servlet{
void callback();
}
public class ServerImpl implements Server{
public void callback(){
System.out.println("线程已经执行完毕");
}
public void static main(String[]){
Server server=new ServerImpl();
ClientThread client=new ClientThread(server);
Thread testClient=new Thread(client);
testClient.start();
}
}
public class ClientThread implements Runnable{
private Server server;
public ClientThread(Server server){
this.server=server;
}
public void run(){
for(int i=0;i<1000;i++){