class Server
{
while(true)
new ClientThread(Socket.accept()).start();
}
class ClientThread extends Thread
{
public void run()
{
ppl.chat(Socket s);//a defined protocol object in my program
}
}
class Protocol
{
public Protocol(Socket s)
{
socket=s;
}
public synchronized void chat()
{
//here i defined socket input output streams and serverinput is a string given by server
if(ServerInput=="wait")
wait();
if(ServerInput=="cont")
notify()
.....................sending infomation-------
}
}
ここで、wait()
このソケットを介して情報を送信できなくなった後、ブロックから離れることができます。待機ブロックから正常に出てくることをテストしました。他のクライアントスレッドから「cont」を与えて通知された場合。誰かが私の問題を解決しますか? よろしくお願いします。