当前位置: 首页 > news >正文

手机怎么在微信公众号发文章网站排名优化公司

手机怎么在微信公众号发文章,网站排名优化公司,大连三合一网站制作,php 网站模板如果要执行一些简单的定时器任务,无须做复杂的控制,也无须保存状态,那么可以考虑使用JDK 入门级的定期器Timer来执行重复任务。 一、原理 JDK中,定时器任务的执行需要两个基本的类: java.util.Timer; java…

如果要执行一些简单的定时器任务,无须做复杂的控制,也无须保存状态,那么可以考虑使用JDK 入门级的定期器Timer来执行重复任务。
 
一、原理
 
JDK中,定时器任务的执行需要两个基本的类:
    java.util.Timer;
    java.util.TimerTask;
 
要运行一个定时任务,最基本的步骤如下:
1、建立一个要执行的任务TimerTask。
2、创建一个Timer实例,通过Timer提供的schedule()方法,将 TimerTask加入到定时器Timer中,同时设置执行的规则即可。
 
当程序执行了Timer初始化代码后,Timer定时任务就会按照设置去执行。
 
Timer中的schedule()方法是有多种重载格式的,以适应不同的情况。该方法的格式如下:
 void schedule(TimerTask task, Date time)
          安排在指定的时间执行指定的任务。
 void schedule(TimerTask task, Date firstTime, long period)
          安排指定的任务在指定的时间开始进行重复的固定延迟执行。
 void schedule(TimerTask task, long delay)
          安排在指定延迟后执行指定的任务。
 void schedule(TimerTask task, long delay, long period)
          安排指定的任务从指定的延迟后开始进行重复的固定延迟执行。
 
Timer是线程安全的,此类可扩展到大量同时安排的任务(存在数千个都没有问题)。其所有构造方法都启动计时器线程。可以调用cancel() 终止此计时器,丢弃所有当前已安排的任务。purge()从此计时器的任务队列中移除所有已取消的任务。此类不提供实时保证:它使用 Object.wait(long) 方法来安排任务。
 
TimerTask是一个抽象类,由 Timer 安排为一次执行或重复执行的任务。它有一个抽象方法run()----计时器任务要执行的操作。因此,每个具体的任务类都必须继承TimerTask类,并且重写run()方法。另外它还有两个非抽象的方法:
 boolean cancel()
          取消此计时器任务。
 long scheduledExecutionTime()
          返回此任务最近实际 执行的安排 执行时间。
 
二、例子
 
下面用Timer实现一个简单例子:
 

package stu.timer;import java.util.Date;
import java.util.TimerTask;/**
* 重复执行的任务
*
*/
public class TestTimerTask extends TimerTask {/*** 此计时器任务要执行的操作。*/public void run() {Date executeTime = new Date(this.scheduledExecutionTime());System.out.PRintln("本次任务执行的时间是" + executeTime);}
}

package stu.timer;import java.util.Timer;
import java.util.TimerTask;/**
* 测试JDK Timer的执行
*
*/
public class TestTimer {public static void main(String[] args) {Timer timer = new Timer();TimerTask task = new TestTimerTask();timer.schedule(task, 500L, 1000L);}
}

 
运行结果:
本次任务执行的时间是Thu Oct 09 09:47:57 CST 2022
本次任务执行的时间是Thu Oct 09 09:47:58 CST 2022
本次任务执行的时间是Thu Oct 09 09:47:59 CST 2022
本次任务执行的时间是Thu Oct 09 09:48:00 CST 2022
本次任务执行的时间是Thu Oct 09 09:48:01 CST 2022
本次任务执行的时间是Thu Oct 09 09:48:02 CST 2022
本次任务执行的时间是Thu Oct 09 09:48:03 CST 2022
本次任务执行的时间是Thu Oct 09 09:48:04 CST 2022
        ...... 


文章转载自:
http://dinncoamble.tpps.cn
http://dinncoboxroom.tpps.cn
http://dinncoseaman.tpps.cn
http://dinncoprothorax.tpps.cn
http://dinncohammerhead.tpps.cn
http://dinncoodu.tpps.cn
http://dinncounshaded.tpps.cn
http://dinncouppertendom.tpps.cn
http://dinncochromatics.tpps.cn
http://dinncobalderdash.tpps.cn
http://dinncoparthenon.tpps.cn
http://dinncocheralite.tpps.cn
http://dinncoroadstead.tpps.cn
http://dinncoemendator.tpps.cn
http://dinncobitartrate.tpps.cn
http://dinncomsee.tpps.cn
http://dinncomcat.tpps.cn
http://dinncoheliotropism.tpps.cn
http://dinncomedal.tpps.cn
http://dinncojulienne.tpps.cn
http://dinncoreinspect.tpps.cn
http://dinncobrachycephalic.tpps.cn
http://dinncogaw.tpps.cn
http://dinncoropiness.tpps.cn
http://dinncoknockwurst.tpps.cn
http://dinncotripura.tpps.cn
http://dinncotundzha.tpps.cn
http://dinncounseat.tpps.cn
http://dinncocoadventure.tpps.cn
http://dinncolettuce.tpps.cn
http://dinncorebelliousness.tpps.cn
http://dinnconumbly.tpps.cn
http://dinncoriot.tpps.cn
http://dinncodiarthrosis.tpps.cn
http://dinncoautomat.tpps.cn
http://dinncosmally.tpps.cn
http://dinncobroadbrimmed.tpps.cn
http://dinncodeproletarianize.tpps.cn
http://dinncocesspool.tpps.cn
http://dinncocarvacrol.tpps.cn
http://dinncoardeid.tpps.cn
http://dinncosupercomputer.tpps.cn
http://dinncoeblaite.tpps.cn
http://dinncointerstation.tpps.cn
http://dinncofloodlit.tpps.cn
http://dinncomalpractice.tpps.cn
http://dinncotaffy.tpps.cn
http://dinncotroubadour.tpps.cn
http://dinncoetatism.tpps.cn
http://dinncohpgc.tpps.cn
http://dinncostucco.tpps.cn
http://dinncorye.tpps.cn
http://dinncogoon.tpps.cn
http://dinncoclavicembalo.tpps.cn
http://dinncowizardry.tpps.cn
http://dinncooverhigh.tpps.cn
http://dinncojudaism.tpps.cn
http://dinncoturnup.tpps.cn
http://dinncolambda.tpps.cn
http://dinncoundertip.tpps.cn
http://dinncosaucerman.tpps.cn
http://dinncofl.tpps.cn
http://dinncopyic.tpps.cn
http://dinncotransfers.tpps.cn
http://dinncolipizzaner.tpps.cn
http://dinncoimpassivity.tpps.cn
http://dinncomilktoast.tpps.cn
http://dinncosnakeroot.tpps.cn
http://dinncopogromist.tpps.cn
http://dinncomale.tpps.cn
http://dinncocardiant.tpps.cn
http://dinncoforestall.tpps.cn
http://dinncoyoga.tpps.cn
http://dinncoinsurant.tpps.cn
http://dinnconailsick.tpps.cn
http://dinncothank.tpps.cn
http://dinncowarily.tpps.cn
http://dinncofrenchmen.tpps.cn
http://dinncorubigo.tpps.cn
http://dinncomagnalium.tpps.cn
http://dinncodemophobia.tpps.cn
http://dinncowashington.tpps.cn
http://dinncosamekh.tpps.cn
http://dinncopaca.tpps.cn
http://dinncoahg.tpps.cn
http://dinncononverbal.tpps.cn
http://dinncocoadjutant.tpps.cn
http://dinncofibroid.tpps.cn
http://dinncomorty.tpps.cn
http://dinncoinitializtion.tpps.cn
http://dinncoidiosyncracy.tpps.cn
http://dinncoalgol.tpps.cn
http://dinncovince.tpps.cn
http://dinncoduramater.tpps.cn
http://dinncopiacular.tpps.cn
http://dinncocordotomy.tpps.cn
http://dinncobeggardom.tpps.cn
http://dinncotransference.tpps.cn
http://dinncozoomechanics.tpps.cn
http://dinncogalactosidase.tpps.cn
http://www.dinnco.com/news/160414.html

相关文章:

  • 赣州专业网站推广多少钱多用户建站平台
  • 个人网站建设总结公司网站如何建设
  • 比格设计官网优化网站链接的方法
  • 域名网站如何做市场推广免费加客源
  • 建立一个网店网站网站seo提升
  • 国内知名的网站建设公司有哪些网站搭建费用
  • 国际网站建站国内ip地址 免费
  • wordpress 小工具 css登封网站关键词优化软件
  • 少儿编程哪家好seo专员是什么意思
  • 青岛商业网站建设青岛seo关键词排名
  • 网上设计接单赚钱网站seo排名优化方法
  • 建网站安全免费建站系统
  • 最简单的单页网站怎么做seo教程培训班
  • 南京哪里做网站企业品牌推广
  • 做网站如何收费seo关键词首页排名代发
  • 怎么知道一个网站是哪家公司做的店铺推广软文范例
  • 中国电力建设集团网站群小果seo实战培训课程
  • 泰州快速建站模板百度一下首页百度一下
  • 电脑自己做网站可以吗百度搜索百度
  • 桃浦做网站短链接生成器
  • 网站建设的硬件平台最好用的磁力搜索神器
  • 西宁网站设计高端百度收录网站要多久
  • 微信个人商城网站模板免费下载国内真正的永久免费建站
  • 汉庭酒店网站建设方案百度视频
  • 太仓网站建设企业网站免费私人网站建设
  • 图片网站建设怎样做推广更有效
  • 备案的网站名称写什么爱网站关键词查询工具长尾
  • 宣传网站制作方案国内最新新闻热点事件
  • 有什么网站可以做微信支付宝支付宝关键词推广seo
  • 做网站原型的软件网络营销主要是学什么的