0

问题:如何通过在我的客户列表中的每个客户中发送多条消息来减少我的项目花费的时间?

这是我的短信课程:

  public void sendSMS(String port, String phoneNumber, String message) throws Exception {

                try {
        OutboundNotification outboundNotification = new OutboundNotification();
        SerialModemGateway gateway = new SerialModemGateway("", port, 9600, "", "");
        gateway.setInbound(true);
        gateway.setOutbound(true);
        //gateway.setSimPin("0000");
        Service.getInstance().setOutboundMessageNotification(outboundNotification);
        Service.getInstance().addGateway(gateway);
         Service.getInstance().startService();
        OutboundMessage msg = new OutboundMessage(phoneNumber, message);
        Service.getInstance().sendMessage(msg);
        Service.getInstance().stopService();
        Service.getInstance().removeGateway(gateway);
        } catch (Exception ex) {
                    System.err.println("test");    
                    Logger.getLogger(SMS.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

这就是我运行时代码的流动方式,我在另一个类中调用 sendms.class

for (Client client1 : client) {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    String num = "";
                    num = client1.getPhonenumber().trim(); 
                    new SMS().sendSMS("COM7",num, taMessageFilter.getText());
                } catch (Exception ex) {
                    new PopupError().text(ex.getMessage());
                }
            }
        });
        t.start();
        try {
            Thread.sleep(20000);
        } catch (InterruptedException ex) {
            Logger.getLogger(Dsms.class.getName()).log(Level.SEVERE, null, ex);
        }

}
4

0 回答 0