我是翡翠的新手,我想建立一个拍卖师代理,给出时间和物品数量,然后......但是我收到此错误
-
翡翠错误代理 A1 在没有正确终止的情况下死亡。 错误 状态 2 我的代码:
int timeout=Integer.parseInt(JOptionPane.showInputDialog("What 's Running Time of Auction in sec?"((;
number=Integer.parseInt(JOptionPane.showInputDialog("What's the number of items?")); //service registration DFAgentDescription dfd = new DFAgentDescription(); dfd.setName(getAID()); ServiceDescription sd = new ServiceDescription(); sd.setType("Uniform-Price-Auction"); sd.setName("Uniform-Price-Auction"); dfd.addServices(sd); try { DFService.register(this, dfd); } catch (FIPAException fe) { fe.printStackTrace(); } // Add the behaviour serving queries from buyer agents addBehaviour(new getBids()); // Add the behaviour serving purchase orders from buyer agents addBehaviour(new DetermineWinner(this,timeout*1000)); gui=new ActioneerGUI(); gui.setVisible(true); gui.setlabel1("We want to sell "+number+" items"); gui.setlabel2("Auction is running...");
考虑到JADE Agent最终是一个Java线程,无论在哪里发生错误,都会导致代理或线程被终止(如果我是对的,这经常发生在AgentWrapper类中(。
另请记住,调用 JOptionPane(即 Swing(会影响两个线程:代理线程和可能导致并发问题的 Swing 线程。最好不要将它们混为一谈;而是通过将最终用户应用程序/可视化与代理分离来使用代理的 O2A 接口。