com.sun.jdi.VMDisconnectedException: Got IOException from Virtual Machine occurr

小贝壳666 2010-02-02 05:33:40
	/**  
* StartClient
*
*/
class StartClient implements Runnable {

public void run() {
try {
Socket socket = null;
boolean flag = true;
while (flag) {
try {
socket = new Socket("127.0.0.1", 10003);
} catch (ConnectException ex) {
ex.printStackTrace();
}
if (socket != null) {
flag = false;
}
}
// 用于获取服务端传输来的信息
BufferedReader buff = new BufferedReader(new InputStreamReader(socket.getInputStream()));

Thread t = null;
String[] arr = null;
while (true) {
String str = buff.readLine(); // 运行时出错行,报的异常如题
if (str != null) {
arr = str.split(" ");
}
if (map.containsKey(arr[0])) {
t = new Thread(new ClientNet(arr));
t.start();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}


单独写一个客户端没有问题,但写到一个线程里就会报com.sun.jdi.VMDisconnectedException: Got IOException from Virtual Machine occurr这个异常,在线等。
...全文
1295 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjz8204 2012-08-29
  • 打赏
  • 举报
回复
我也遇到这类问题,但不是写socket时遇到的,是调用外部dll中的函数时,报这个错。正在找解决办法。
穿裤衩闯天下 2012-06-28
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

端口被占用引起的
[/Quote]
那怎么解决呢?
小贝壳666 2010-02-02
  • 打赏
  • 举报
回复
端口被占用引起的
小贝壳666 2010-02-02
  • 打赏
  • 举报
回复
当写到一个线程中时
String str = buff.readLine(); // 运行时出错

异常:com.sun.jdi.VMDisconnectedException: Got IOException from Virtual Machine occurr

跪求解决方案。。。

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧