java.util.timertask_java.util.TimerTask翻译

java.util

Class TimerTask

java.lang.Object

0818b9ca8b590ca3270a3433284dd417.pngjava.util.TimerTask

All Implemented Interfaces:

public abstract class TimerTask

extends

Object

implements

Runnable

A task that can be scheduled for one-time or repeated execution by a Timer. 由Timer安排执行一次或重复执行的任务。

Since:

1.3

See Also:

Constructor Summary

protected

Creates a new timer task. 创建一个新的计时任务。

Method Summary

boolean

Cancels this timer task. 取消该计时任务。

abstract  void

The action to be performed by this timer task. 由计时任务执行的动作。

long

Returns the scheduled execution time of the most recent actual execution of this task. 返回该任务安排的最近实际执行的执行时间。

Constructor Detail

TimerTask

protected TimerTask()

Creates a new timer task. 创建一个新的计时任务。

Method Detail

run

public abstract void run()

The action to be performed by this timer task. 由计时任务执行的动作。

Specified by:

in interface

cancel

public boolean cancel()

Cancels this timer task. If the task has been scheduled for one-time execution and has not yet run, or has not yet been scheduled, it will never run. If the task has been scheduled for repeated execution, it will never run again. (If the task is running when this call occurs, the task will run to completion, but will never run again.) 取消该计时任务。如果任务已被安排为一次执行并且还没有运行或者还没有被安排,它将不会运行。如果任务被安排为重复执行,它将不会再次运行。(如果调用时任务正在运行,任务将运行至结束,但不会再次运行。)

Note that calling this method from within the run method of a repeating timer task absolutely guarantees that the timer task will not run again. 注意在一个重复计时任务的run方法调用此方法可以绝对担保计时任务不会再次运行。

This method may be called repeatedly; the second and subsequent calls have no effect. 该方法可以重复调用,但第二次及其后的调用不起作用。

Returns:

true if this task is scheduled for one-time execution and has not yet run, or this task is scheduled for repeated execution. Returns false if the task was scheduled for one-time execution and has already run, or if the task was never scheduled, or if the task was already cancelled. (Loosely speaking, this method returns true if it prevents one or more scheduled executions from taking place.) 如果任务被安排为一次执行而没有运行,或者被安排为重复执行,返回true。 如果任务被安排为一次执行而已经运行,或者任务还没有被安排,或者任务已经被取消,返回false。 (粗略地讲,如果方法阻止一次或多次被安排执行的发生,返回true。)

scheduledExecutionTime

public long scheduledExecutionTime()

Returns the scheduled execution time of the most recent actual execution of this task. (If this method is invoked while task execution is in progress, the return value is the scheduled execution time of the ongoing task execution.) 返回该任务最近实际执行所安排的执行时间。(如果方法调用时任务执行正在进行,那么返回正在进行任务执行的安排执行时间值。)

This method is typically invoked from within a task's run method, to determine whether the current execution of the task is sufficiently timely to warrant performing the scheduled activity: 该方法通常在任务的run方法中调用,用来确定是否当前执行的任务是否足够及时保证执行安排的动作:

public void run() {

if (System.currentTimeMillis() - scheduledExecutionTime() >=

MAX_TARDINESS)

return; // Too late; skip this execution.

// Perform the task

}

This method is typically not used in conjunction with fixed-delay execution repeating tasks, as their scheduled execution times are allowed to drift over time, and so are not terribly significant. 该方法通常不在固定延迟的执行重复任务的连接中使用,因为 它们的执行时间允许超时,所以意义不明显。

Returns:

the time at which the most recent execution of this task was scheduled to occur, in the format returned by Date.getTime(). The return value is undefined if the task has yet to commence its first execution. 任务的最近执行被安排的时间,以格式Date.getTime()返回。如果任务还未开始它的第一次执行, 返回值不确定。

See Also:

Submit a bug or feature

For further API reference and developer documentation, see

Java 2 SDK SE Developer Documentation

. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject tolicense terms. Also see thedocumentation redistribution policy.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/527744.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

java还值_Java到底是引用传递还是值传递

前言前段时间在群里看到类似这样一个问题,下面的代码会输出什么呢?public void test(){String str "hello";change(str);System.out.println(str);}private void change(String str){str "world";}当时看到这题,瞬间勾…

什么是java中的面向对象编程_什么是面向对象编程

什么是面向对象编程时间:2018-01-23 来源:面向对象编程讲解一.前言其实不管是java还是.net都是属于面向对象程序设计语言,归根结底,它们都离不开面向对象,所以什么是面向对象呢,意思就是object-oriente…

java两个长度不同数组_两组数组,长度不一样,如果其中一个数组的值在另一个中不存在,则不符合要求.怎么算?...

思路一先找到最长的数组,然后循环短的数组并判断元素是否在长数组中public class Main {public static void main(String[] args) throws CloneNotSupportedException {String[] strArr1{"ee","aa","bb","cc"};String[] st…

java如何给顺序表赋值_JAVA模拟新增顺序表及单链表

最近在回顾大学学的数据结构,这里给大家用javwww.cppcns.coma模拟顺序表和单链表的新增1顺序表新增/*** 顺序www.cppcns.com表** author cjd**/public class ArrayList {private Object[] elementData; // 底层是一个数组,目前还没有确定长度private int…

php sql查询两个表语句,sql多表查询语句与方法

sql多表查询有很多种方法,如有自然连接 INNER JOIN,外边查询LEFT JOIN,交叉查询JOIN,交叉连接JOIN等join on left on 等多的是哦。sql多表查询语句与方法sql多表查询有很多种方法,如有自然连接 INNER JOIN,外边查询LEFT JOIN,交叉查询JOIN,交叉连接JOIN等…

php浏览服务器某一文件夹内容,php删除web服务器中指定目录下的指定格式的文件...

今天还在写VipSystem Pro的授权部分,用户授权后,生成匹配该用户的唯一的php文件集合(在一个目录下),然后进行zip下所并弹出下载。这个临时生成的zip文件存放在我指定的一个目录。每个用户授权不同的功能,都会产生一个唯一的zip压缩…

PHP的html实现xpath解析,php用xpath解析html的代码实例讲解

实例1$xml simplexml_load_file(https://forums.eveonline.com);$names $xml->xpath("html/body/p/p/form/p/p/p/p/p[*]/p/p/table//tr/td[classtopicViews]");foreach($names as $name){echo $name . "";}实例2$url http://www.baidu.com;$ch curl…

php phpexcel用法,PHPExcel用法总结

PHPExcel用法总结总结一下PHPExcel的用法~//设置PHPExcel类库的include path//这里貌似直接include类文件就可以了# set_include_path(.. PATH_SEPARATOR .# ExcelPHP_LIBS . PATH_SEPARATOR .# get_include_path());/*** 以下是使用示例&am…

nginx php value,PHP+NGINX参数优化

Failed requests: 0Write errors: 0Requests per second: 3712.72 [#/sec] (mean)Time per request: 134.672 [ms] (mean)Time per request: 0.269 [ms] (mean, across all concurrent requests)Transfer rate: 732.37 [Kbytes/sec] received1000并发:Concurrency L…

php追加数据,php追加数据到mysql

追加数据 php mysqlphp追加数据到mysql在mysql里的一个表user中有个name的字段表中已经有一条记录id字段值是1name字段的值是”周”我现在想追加”杰伦”两个字到这个字段中也就是让这条记录的name字段的值从原来的”周”变成现在的”周杰伦”请问要怎么操作呢?如何…

php escapeshellcmd,利用/绕过 PHP escapeshellarg/escapeshellcmd函数

escapeshellarg和escapeshellcmd的功能escapeshellarg1.确保用户只传递一个参数给命令2.用户不能指定更多的参数一个3.用户不能执行不同的命令escapeshellcmd1.确保用户只执行一个命令2.用户可以指定不限数量的参数3.用户不能执行不同的命令让我们用groups去打印组里每个userna…

php 绕waf,【技术分享】php webshell分析和绕过waf技巧

作者:阻圣预估稿费:400RMB(不服你也来投稿啊!)投稿方式:发送邮件至linwei#360.cn,或登陆网页版在线投稿前言WebShell是攻击者使用的恶意脚本,它的用途主要是在攻击后的Web应用程序上建立持久性的后门。webs…

php写好程序后需要嵌套,什么是PHP嵌套函数?

这不仅是副作用,而且实际上是动态修改程序逻辑的非常有用的功能。它来自过程式PHP时代,但如果您想以最直接的方式为某些独立功能提供替代实现,那么它也可以与OO体系结构一起使用。(虽然在大多数情况下,OO是更好的选择,…

java 电子实时看板,看板界面的实现

在系统中有时通过以下界面可以直观的展示信息给用户:以上图形有几点比较重要:1, 一个面板显示一组属性(例如物料显示物料编号、物料规格),但要把最主要的属性通过颜色单独处分出来。2, 通过颜色来区分重要性,例如(红…

java https soap,Java Https Soap Server(Tomcat-Axis2)

1、%Tomcat%/server/server.xml找到下面一段:替换为:maxThreads"150" scheme"https" secure"true"clientAuth"false" sslProtocol"TLS"disableUploadTimeout"true" enableLookups"fal…

php在線評論,php在線生成pdf筆記 | 學步園

準備工作:網上下載fpdf類。網上下載chinese類,此類主要是讓pdf支持中文。實例:require(chinese.php);$pdfnew PDF_Chinese();mysql_connect(localhost,root,fkey);mysql_selectdb(mylib);mysql_query("SET NAMES uft-8");$query m…

php数组能不能静态,php 为什么常量可以用数组定义 静态变量却不能

<?php$GLOBALS[arr] array(1>1,2>2);define("ABC",$GLOBALS[arr][1]); # 这个定义可以class test{static $a $GLOBALS[arr][1]; # 这个初始化有语法错误}类的变量成员叫做“属性”&#xff0c;或者叫“字段”、“特征”&#xff0c;在本文档统一称为“属…

matlab简单程序实例视频,matlab编程实例100例.docx

matlab编程实例100例1-32是&#xff1a;图形应用篇33-66是&#xff1a;界面设计篇67-84是&#xff1a;图形处理篇85-100是&#xff1a;数值分析篇实例1&#xff1a;三角函数曲线(1)function shili01h0figure(toolbar,none,... position,[198 56 350 300],... name,实例01);h1ax…

java.net.url 中文乱码,.Net获取URL中文参数值的乱码问题解决方法总结

本文总结分析了.Net获取URL中文参数值的乱码问题解决方法。分享给大家供大家参考&#xff0c;具体如下&#xff1a;解决方法&#xff1a;1.设置web.config文件2.传递中文之前&#xff0c;将要传递的中文参数进行编码&#xff0c;在接收时再进行解码。string Name "中文参…

php里运行js,在PHP 中运行JS - mickelfeng的个人空间 - OSCHINA - 中文开源技术交流社区...

这天去zend网站上逛了逛&#xff0c; 看到一个monkeyspider 的标签&#xff0c;http://devzone.zend.com/article/4704-Using-JavaScript-in-PHP-with-PECL-and-SpiderMonkey嘿嘿&#xff0c; 原来是用c写了一个扩展php扩展 把spiderMonkey和php 联起来了。 照着试了试&#xf…