日期:2014-05-20  浏览次数:20633 次

求救!!我写的单个线程会自动随机地停止
求高人就我:
我的线程代码如下:  
每次启动后,工作一个不确定的时间后(运行100多次,或者10几次)就会自己死掉.   我实在找不出问题了.
public   class   mapSetup     extends   Thread   {
        private   ArrayList <Shape>   shape;
        private   int[][][]   vertex;                          
        private   Canvas   mc;
        private   static   int   isx=0;
        /**   Creates   a   new   instance   of   mapSetup   */
       
        public   mapSetup(Canvas   C   ,ArrayList <Shape>   sa   )   {
                shape=   sa;
                mc=C;
                vertex   =   initVertex();
                this.setDaemon(true);
        }
        public   mapSetup(int[][][]   v   )   {
                vertex   =   v;
        }
        /***************   methord       for   function   **************/
        public   void   run()   {
                int[]   yy={110,110};
                int   count   =40;
                try{
                        while(true){
                                if   (count> 19)   {
                                        yy   =readVertex();
                                        calculateVertex(yy   ,   vertex);
                                        System.out.println(this.getClass()+ "[y1= "  
                                                +   yy[0]+ "],[y2   = "   +yy[1]+ "]   |   count   =   "   +   count);
                                        count=0;
                                }
                                else   {
                                        moveVertex(vertex);