也许有具体的环境可能好回答一些。下面是源代码。这段程序用来做后台工作,每隔5分钟对文件做一次自动保存。
public class AutoSave extends Thread
{ FileSaver model;
public AutoSave(FileSaver m);
{super("AutoSave Thread");
setDaemon(true);
model=m;
}
public void run()
{
while(true)
{try{sleep(300*1000);
}
catch(InterruptedException e){}
if(model.wantAutoSave()&&model.hasUnsavedChanges())
model.saveFile(null);
}
}
public class AutoSave extends Thread
{ FileSaver model;
public AutoSave(FileSaver m);
{super("AutoSave Thread");
setDaemon(true);
model=m;
}
public void run()
{
while(true)
{try{sleep(300*1000);
}
catch(InterruptedException e){}
if(model.wantAutoSave()&&model.hasUnsavedChanges())
model.saveFile(null);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货