public class main_start 
{ /**
 * @param args
 */
public static void main(String[] args) 
{
// TODO Auto-generated method stub
ami_billing billing=new ami_billing();
Thread t=new Thread(billing);
t.start(); }}billing的run方法里运行一个死循球
while(true)
这个程序有没有问题?

解决方案 »

  1.   

    既然用到了while(true),那么肯定得在循环体里有一个是用来做条件判断的处理,并且这个处理中有break操作,而且还得运行过程中一定有满足触发break动作的数据,这样就没有死循环了,你查看一下代码,跟一下数据,单看这些代码只能给这么多意见
      

  2.   

    线程一般都是while(true)吧!!!!
      

  3.   

    private void update_caller(String caller,String callee,String uniqueid)
    {
    mylog.info("update_caller");
    Connection mysql_conn= mysqlConnect();
    String sql="update web_callsinfo set callfrom='"+caller+"',callto='"+callee+"'";
    sql+=" where sessionid='"+uniqueid+"'";
    Statement stmt=null;
    try
    {
    stmt=mysql_conn.createStatement();
    stmt.executeUpdate(sql);
    stmt.close();
    mysql_conn.close();
    mylog.info("update_caller end");
    }
    catch(Exception ex)
    {
    mylog.warn("371"+ex.getMessage());
    }

    }日志
    16:46:24:INFO [Thread-1] lang.Class (update_caller:357) - update_caller
    16:46:35:INFO [Thread-1] lang.Class (update_caller:368) - update_caller end
    这段代码从开始到结束运行了11秒这个是什么问题?