问题描述
在JDK1.4下的环境中,根据1000ms内接收的信息数量来决定是否立即刷新还是延迟刷新,主要原因是如果每次接到消息都即时刷新屏幕的话,就会死机,(特别是当一下子接收到几百上千的消息时).if(message.trim().startsWith(ContactsEntry.CONTACT_RECEIVED_MESSGAE_PREFIX)){//System.out.println("ThecontactTimer"+(null==contactTimer)+",ThecontactReloadTimer"+(null==contactReloadTimer));messageCount++;if(null==contactTimer){contactTimer=newTimer();}contactTask=newTimerTask(){publicvoidrun(){intsize=recieveInterval/(messageCount*avageTime);System.out.println("************Thesizeis"+size+",ThemessageCountis****************"+messageCount);if(size<3){rightNowReload=false;}else{rightNowReload=true;}//-----------------------------根据rightNowReload判断是否立即加载-----------------------------------------if(rightNowReload){System.out.println(".........rightNowReload.........");GetPersonList.handleRecivedMessage(message);rightNowReload=false;messageCount=0;contactTimer.cancel();contactTimer=null;}else{if(null==contactReloadTimer){contactReloadTimer=newTimer();}timerTask=newTimerTask(){publicvoidrun(){System.out.println(".........NotrightNowReload............");GetPersonList.handleRecivedMessage(message);rightNowReload=false;messageCount=0;contactTimer.cancel();contactTimer=null;contactReloadTimer.cancel();contactReloadTimer=null;}};contactReloadTimer.schedule(timerTask,queryInterval);}//contactTimer.cancel();//contactTimer=null;//messageCount=0;}};contactTimer.schedule(contactTask,recieveInterval);以上代码是有问题的,望大神们能给予建议或者好的方案
解决方案
解决方案二:
没有格式看起来真是。。。。每次刷新卡死就每XX条刷新一次建议你去java板块问