关于彩信mms的程序
源代码在线查看: main.java~61~
package mmscenter; public class Main extends Engine{ GetNewMmsToPool getNewMmsToPool =null; SendThread sendThread =null; ResendThread resendThread =null; WriteLog writeLog = null; getIniString ini =null; public Main() { super("Main"); setDaemon(true); } public boolean ReadIni(){ try{ System.out.println("请不要用鼠标点击command窗口。如果点击了,请回车!"); Config.odbcstring = ini.getString("[LOCALDB]","odbcstring") ; System.out.println(" 数据库连接驱动 : "+ Config.odbcstring ); Config.db_host=ini.getString("[LOCALDB]","host"); System.out.println(" 数据库IP地址 : "+Config.db_host); Config.db_name=ini.getString("[LOCALDB]","name"); System.out.println(" 数据库名称 : "+Config.db_name); Config.db_user=ini.getString("[LOCALDB]","user"); System.out.println(" 数据库用户名 : "+Config.db_user); Config.db_password=ini.getString("[LOCALDB]","password"); System.out.println(" 数据库密码 : "+Config.db_password ); //万维的认证 Config.user = ini.getString("[MMSCenter]","username"); System.out.println(" 万维网关用户名 : "+Config.user ); Config.password = ini.getString("[MMSCenter]","password"); System.out.println(" 万维网关密码 : "+Config.password ); Config.protocol = ini.getString("[MMSCenter]","protocal"); System.out.println(" MMS包传输协议 : "+Config.protocol ); Config.ip=ini.getString("[MMSCenter]","ip"); System.out.println(" 万维网关IP : "+Config.ip ); Config.port=ini.getString("[MMSCenter]","port"); System.out.println(" 万维网关开放端口 : "+Config.port ); Config.subfolder=ini.getString("[MMSCenter]","subfolder"); System.out.println(" 万维网关接口路径 : "+Config.subfolder ); return true; }catch(Exception e){ return false; } } public void run(){ ini = new getIniString(); System.out.println(" 读入配置文件 : "+ReadIni()); getNewMmsToPool = new GetNewMmsToPool(); sendThread = new SendThread(); resendThread = new ResendThread(); writeLog = new WriteLog(); while(true){ System.out.println(""); // System.out.println(Utility.getTimeStr()); // if((Utility.getTimeStr()).startsWith("0000")){//00dian00fen线程重起 // // try{ // System.out.println("每天重起线程"); // getNewMmsToPool.shutdown() ; // System.out.println("getNewMmsToPool线程关闭"); // getNewMmsToPool.nap() ; // getNewMmsToPool.interrupt() ; // getNewMmsToPool.startup() ; // System.out.println("getNewMmsToPool线程重新启动"); // sendThread.shutdown() ; // System.out.println("sendThread线程关闭"); // sendThread.nap() ; // sendThread.interrupt() ; // sendThread.startup() ; // System.out.println("sendThread线程重新启动"); // resendThread.shutdown(); // System.out.println("resendThread线程关闭"); // resendThread.nap() ; // resendThread.interrupt() ; // resendThread.startup() ; // System.out.println("resendThread线程重新启动"); // }catch(Exception e){ // e.printStackTrace() ; // }; // try{ // sleep(TimeConfig.TIME_ONE_MINUTE/2); // }catch(Exception e){ // e.printStackTrace() ; // } // } if(!getNewMmsToPool.isRunning() ||!getNewMmsToPool.isAlive() ){ getNewMmsToPool.startup() ; System.out.println("getNewMmsToPool线程启动"); } if(!sendThread.isRunning() || !sendThread.isAlive() ){ sendThread.startup() ; System.out.println("sendThread线程启动"); } if(!resendThread.isRunning() || !resendThread.isAlive() ){ resendThread.startup() ; System.out.println("resendThread线程启动"); } if(!writeLog.isRunning() || !writeLog.isAlive() ){ writeLog.startup() ; System.out.println("WriteLog线程启动"); } try{ sleep(TimeConfig.TIME_ONE_MINUTE/2); }catch(Exception e){ e.printStackTrace() ; } } } public static void main(String[] args) { Main main1 = new Main(); main1.startup() ; while(true){ try{ sleep(TimeConfig.TIME_ONE_MINUTE); }catch(Exception e){ e.printStackTrace() ; } } } }