【发布时间】:2012-12-26 13:17:58
【问题描述】:
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”来通知它时。
有人解决我的问题吗?感谢您的提前。
【问题讨论】:
标签: java multithreading sockets networking