Page 200 - 捷運技術 第28期
P. 200

194                                                28         92    2






                      public class ScheduleRoutine {
                       Timer timerTcp;
                         public ScheduleRroutine(int hourse) {
                         timerTcp = new Timer();
                           timerTcp.scheduleAtFixedRate(new Tcp1Task(),new Date(2003,1,1,3,0,0) ,
               24*60*60*1000);    //1  1   03:00
                    timerTcp.scheduleAtFixedRate(new Tcp2Task(),new Date(2003,1,1,4,0,0) , 24*60*60*1000);
               //1  1  04:00
                                           }
                       class Tcp1Task extends TimerTask {
                        public void run() {
                           Tcp1
                       }
                                         }
                       class Tcp2Task extends TimerTask {
                        public void run() {
                            Tcp2
                                }
                                          }
                    } // scheduleRoutine


                              Tcp1    Tcp2                               TCP/IP          Tcp1


                                   TimerTask    run()

               cm                v               sps                               cpsTcp              sps
                                        cm           sps             sps           Acknowledge      cmd
                                     sps                                          Vector class        Java

                                                    Queue    List               Tcp2
                                                 Tcp1                 Tcp2
               cmd                sps                                  cmd



                    // v   Vector                         sps                 InetAddress
                    // cm   paraDload                sps
                    for (Enumeration es = v.elements() ; es.hasMoreElements() ;)
                    {
                    try {
                    InetAddress ad=(InetAddress) es.nextElement();
                    cpsTcp  k=new cpsTcp( ad,6800,cm); //sps  Tcp1 port  6800
                    k.start();
                    k.join();
   195   196   197   198   199   200   201   202   203   204   205