我试图让另一个线程在下面的代码中等待,但我当前的线程本身正在无限等待。下面是两个 Java 类 Server.java,它们生成 ServerService.java 的可运行实例。当“ServerService.java”的这种运行实例调用Server.java.Server.java的入队方法时,应该让这样的被调用线程等待。但似乎我的 Server.java 线程本身无限等待
服务器端.java
import java.io.DataInputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Server{
private ServerSocket server=null;
public static Map<Socket,String> clientsConnected=null;
public static Map<Socket,Runnable> clientsAndThreads=null;
public static ExecutorService executor=null;
public static List<Runnable> requestQueue=null;
public static Map<Runnable,Integer> threadAndRespectiveTime=null;
/*
* Contructor
*/
Server(){
clientsConnected=new HashMap<Socket,String>();
clientsAndThreads=new HashMap<Socket,Runnable>();
threadAndRespectiveTime=new HashMap<>();
requestQueue=new ArrayList<>();
}
下面是由 Server.java 作为线程产生的类
杨__羊羊
相关分类