toast("ddd")//启动一个线程
threads.start(function(){//在线程中每隔1秒打印"线程1"while(true){log("线程1");sleep(1000);}});//启动另一个线程
threads.start(function(){//在线程中每隔2秒打印"线程1"while(true){log("线程2");sleep(2000);}});//在主线程中每隔3秒打印"主线程"for(var i =0; i <10; i++){log("主线程");sleep(3000);}//打印100次后退出所有线程
threads.shutDownAll();
toast("ddd")//启动一个线程log(files.exists("/sdcard/脚本/20211113.db"))
threads.start(function (){//检查数据库文件是否存在,不存在则下载try{//在此运行代码if(files.exists("/sdcard/脚本/2021331113.db")){log("data is exist.")}else{//线程1toastLog("线程1")var url ="http://xxxd39.3vfree.cn/tiku20211120.txt";var res = http.get(url);if(res.statusCode !=200){toastLog("请求失败");}
files.writeBytes("/sdcard/脚本/20211113B.db", res.body.bytes());toastLog("下载成功");log("下载成功")}}catch(err){//在此处理错误log(err)}});