admin管理员组

文章数量:1530279

Warning: To avoid potential deadlock, operations that may block, such as
 networking, should be performed in a different thread than the
 commandAction() handler.

开发j2me出现的网络连接异常,该异常的意思就是说: 如果你没有使用一个单独的线程来做连接的话,那么该程序就可能出现  潜在的死锁,操作可能会阻塞...

 

解决办法: 为连接开辟一个新的线程:

 

   方法一:

    

    Runnable runnable = new Runnable

    {  
         public void run()

       {   
                  do();   
           }   
     }
    new Thread(runnable ).start();   
   
   在类中加入方法do()  
   在这个方法中完成网络连接的工作。

  

   方法二:

    new   Thread(){
      public   void   run(){   
                do();  
      }
    }.start();  
   

    注意:在 run 内部使用外部的 this ,也就是外部的对象不能直接 this,  您可以用  外部的类名.this

转载于:https://wwwblogs/visoeclipse/archive/2009/11/11/1600830.html

本文标签: potentialavoidwarningBlockOperations