好像是这个啊,不过,貌似还要考虑浏览器缓存 ------其他解决方案-------------------- 那你的那个流肯定是个静态变量或者全局变量,把他弄成局部的就可以了 ------其他解决方案-------------------- 话说,你的is 、os 都不关,很给力啊! ------其他解决方案-------------------- 我也相关了啊,可是一关就出现异常: java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2554)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1297)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at com.manager.userFrame.readyFrame.run(readyFrame.java:51)
at java.lang.Thread.run(Thread.java:619)
------其他解决方案-------------------- for (int i = 0; i < v.size(); ++i) {
System.out.println("在线用户包");
ObjectOutputStream oos = new ObjectOutputStream(v.get(i).s.getOutputStream());
ObjectInputStream ois =new ObjectInputStream(v.get(i).s.getInputStream());
oos.writeObject(m);
oos.flush();
}这样写的话,第一个人上线可以正常向大伙发送在线包,但是第二个人一上线就报错了了:java.io.StreamCorruptedException: invalid type code: AC
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1356)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at com.manager.userFrame.readyFrame.run(readyFrame.java:51)
at java.lang.Thread.run(Thread.java:619)
}
------其他解决方案--------------------
public UserGroup(Socket s , String id , String name){//初始化用户的Socket,id,name
this.socket = s;
this.id = id ;
this.name = name ;
System.out.println("new 一个用户到用户组");