⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.html

📁 API資料大全
💻 HTML
📖 第 1 页 / 共 2 页
字号:
</DL><HR><A NAME="Timer(boolean)"><!-- --></A><H3>Timer</H3><PRE>public <B>Timer</B>(boolean&nbsp;isDaemon)</PRE><DL><DD>Creates a new timer whose associated thread may be specified to  run as a daemon.  A deamon thread is called for if the timer will be used to schedule repeating "maintenance activities", which must be performed as long as the application is running, but should not prolong the lifetime of the application.<DD><DL><DT><B>Parameters:</B><DD><CODE>isDaemon</CODE> - true if the associated thread should run as a daemon.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Thread.html"><CODE>Thread</CODE></A>, <A HREF="../../java/util/Timer.html#cancel()"><CODE>cancel()</CODE></A></DL></DD></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="schedule(java.util.TimerTask, long)"><!-- --></A><H3>schedule</H3><PRE>public void <B>schedule</B>(<A HREF="../../java/util/TimerTask.html">TimerTask</A>&nbsp;task,                     long&nbsp;delay)</PRE><DL><DD>Schedules the specified task for execution after the specified delay.<DD><DL><DT><B>Parameters:</B><DD><CODE>task</CODE> - task to be scheduled.<DD><CODE>delay</CODE> - delay in milliseconds before task is to be executed.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <tt>delay</tt> is negative, or         <tt>delay + System.currentTimeMillis()</tt> is negative.<DD><CODE><A HREF="../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if task was already scheduled or         cancelled, or timer was cancelled.</DL></DD></DL><HR><A NAME="schedule(java.util.TimerTask, java.util.Date)"><!-- --></A><H3>schedule</H3><PRE>public void <B>schedule</B>(<A HREF="../../java/util/TimerTask.html">TimerTask</A>&nbsp;task,                     <A HREF="../../java/util/Date.html">Date</A>&nbsp;time)</PRE><DL><DD>Schedules the specified task for execution at the specified time.  If the time is in the past, the task is scheduled for immediate execution.<DD><DL><DT><B>Parameters:</B><DD><CODE>task</CODE> - task to be scheduled.<DD><CODE>time</CODE> - time at which task is to be executed.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <tt>time.getTime()</tt> is negative.<DD><CODE><A HREF="../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if task was already scheduled or         cancelled, timer was cancelled, or timer thread terminated.</DL></DD></DL><HR><A NAME="schedule(java.util.TimerTask, long, long)"><!-- --></A><H3>schedule</H3><PRE>public void <B>schedule</B>(<A HREF="../../java/util/TimerTask.html">TimerTask</A>&nbsp;task,                     long&nbsp;delay,                     long&nbsp;period)</PRE><DL><DD>Schedules the specified task for repeated <i>fixed-delay execution</i>, beginning after the specified delay.  Subsequent executions take place at approximately regular intervals separated by the specified period. <p>In fixed-delay execution, each execution is scheduled relative to the actual execution time of the previous execution.  If an execution is delayed for any reason (such as garbage collection or other background activity), subsequent executions will be delayed as well. In the long run, the frequency of execution will generally be slightly lower than the reciprocal of the specified period (assuming the system clock underlying <tt>Object.wait(long)</tt> is accurate). <p>Fixed-delay execution is appropriate for recurring activities that require "smoothness."  In other words, it is appropriate for activities where it is more important to keep the frequency accurate in the short run than in the long run.  This includes most animation tasks, such as blinking a cursor at regular intervals.  It also includes tasks wherein regular activity is performed in response to human input, such as automatically repeating a character as long as a key is held down.<DD><DL><DT><B>Parameters:</B><DD><CODE>task</CODE> - task to be scheduled.<DD><CODE>delay</CODE> - delay in milliseconds before task is to be executed.<DD><CODE>period</CODE> - time in milliseconds between successive task executions.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <tt>delay</tt> is negative, or         <tt>delay + System.currentTimeMillis()</tt> is negative.<DD><CODE><A HREF="../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if task was already scheduled or         cancelled, timer was cancelled, or timer thread terminated.</DL></DD></DL><HR><A NAME="schedule(java.util.TimerTask, java.util.Date, long)"><!-- --></A><H3>schedule</H3><PRE>public void <B>schedule</B>(<A HREF="../../java/util/TimerTask.html">TimerTask</A>&nbsp;task,                     <A HREF="../../java/util/Date.html">Date</A>&nbsp;firstTime,                     long&nbsp;period)</PRE><DL><DD>Schedules the specified task for repeated <i>fixed-delay execution</i>, beginning at the specified time. Subsequent executions take place at approximately regular intervals, separated by the specified period. <p>In fixed-delay execution, each execution is scheduled relative to the actual execution time of the previous execution.  If an execution is delayed for any reason (such as garbage collection or other background activity), subsequent executions will be delayed as well. In the long run, the frequency of execution will generally be slightly lower than the reciprocal of the specified period (assuming the system clock underlying <tt>Object.wait(long)</tt> is accurate). <p>Fixed-delay execution is appropriate for recurring activities that require "smoothness."  In other words, it is appropriate for activities where it is more important to keep the frequency accurate in the short run than in the long run.  This includes most animation tasks, such as blinking a cursor at regular intervals.  It also includes tasks wherein regular activity is performed in response to human input, such as automatically repeating a character as long as a key is held down.<DD><DL><DT><B>Parameters:</B><DD><CODE>task</CODE> - task to be scheduled.<DD><CODE>firstTime</CODE> - First time at which task is to be executed.<DD><CODE>period</CODE> - time in milliseconds between successive task executions.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <tt>time.getTime()</tt> is negative.<DD><CODE><A HREF="../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if task was already scheduled or         cancelled, timer was cancelled, or timer thread terminated.</DL></DD></DL><HR><A NAME="scheduleAtFixedRate(java.util.TimerTask, long, long)"><!-- --></A><H3>scheduleAtFixedRate</H3><PRE>public void <B>scheduleAtFixedRate</B>(<A HREF="../../java/util/TimerTask.html">TimerTask</A>&nbsp;task,                                long&nbsp;delay,                                long&nbsp;period)</PRE><DL><DD>Schedules the specified task for repeated <i>fixed-rate execution</i>, beginning after the specified delay.  Subsequent executions take place at approximately regular intervals, separated by the specified period. <p>In fixed-rate execution, each execution is scheduled relative to the scheduled execution time of the initial execution.  If an execution is delayed for any reason (such as garbage collection or other background activity), two or more executions will occur in rapid succession to "catch up."  In the long run, the frequency of execution will be exactly the reciprocal of the specified period (assuming the system clock underlying <tt>Object.wait(long)</tt> is accurate). <p>Fixed-rate execution is appropriate for recurring activities that are sensitive to <i>absolute</i> time, such as ringing a chime every hour on the hour, or running scheduled maintenance every day at a particular time.  It is also appropriate for for recurring activities where the total time to perform a fixed number of executions is important, such as a countdown timer that ticks once every second for ten seconds.  Finally, fixed-rate execution is appropriate for scheduling multiple repeating timer tasks that must remain synchronized with respect to one another.<DD><DL><DT><B>Parameters:</B><DD><CODE>task</CODE> - task to be scheduled.<DD><CODE>delay</CODE> - delay in milliseconds before task is to be executed.<DD><CODE>period</CODE> - time in milliseconds between successive task executions.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <tt>delay</tt> is negative, or         <tt>delay + System.currentTimeMillis()</tt> is negative.<DD><CODE><A HREF="../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if task was already scheduled or         cancelled, timer was cancelled, or timer thread terminated.</DL></DD></DL><HR><A NAME="scheduleAtFixedRate(java.util.TimerTask, java.util.Date, long)"><!-- --></A><H3>scheduleAtFixedRate</H3><PRE>public void <B>scheduleAtFixedRate</B>(<A HREF="../../java/util/TimerTask.html">TimerTask</A>&nbsp;task,                                <A HREF="../../java/util/Date.html">Date</A>&nbsp;firstTime,                                long&nbsp;period)</PRE><DL><DD>Schedules the specified task for repeated <i>fixed-rate execution</i>, beginning at the specified time. Subsequent executions take place at approximately regular intervals, separated by the specified period. <p>In fixed-rate execution, each execution is scheduled relative to the scheduled execution time of the initial execution.  If an execution is delayed for any reason (such as garbage collection or other background activity), two or more executions will occur in rapid succession to "catch up."  In the long run, the frequency of execution will be exactly the reciprocal of the specified period (assuming the system clock underlying <tt>Object.wait(long)</tt> is accurate). <p>Fixed-rate execution is appropriate for recurring activities that are sensitive to <i>absolute</i> time, such as ringing a chime every hour on the hour, or running scheduled maintenance every day at a particular time.  It is also appropriate for for recurring activities where the total time to perform a fixed number of executions is important, such as a countdown timer that ticks once every second for ten seconds.  Finally, fixed-rate execution is appropriate for scheduling multiple repeating timer tasks that must remain synchronized with respect to one another.<DD><DL><DT><B>Parameters:</B><DD><CODE>task</CODE> - task to be scheduled.<DD><CODE>firstTime</CODE> - First time at which task is to be executed.<DD><CODE>period</CODE> - time in milliseconds between successive task executions.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <tt>time.getTime()</tt> is negative.<DD><CODE><A HREF="../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if task was already scheduled or         cancelled, timer was cancelled, or timer thread terminated.</DL></DD></DL><HR><A NAME="cancel()"><!-- --></A><H3>cancel</H3><PRE>public void <B>cancel</B>()</PRE><DL><DD>Terminates this timer, discarding any currently scheduled tasks. Does not interfere with a currently executing task (if it exists). Once a timer has been terminated, its execution thread terminates gracefully, and no more tasks may be scheduled on it. <p>Note that calling this method from within the run method of a timer task that was invoked by this timer absolutely guarantees that the ongoing task execution is the last task execution that will ever be performed by this timer. <p>This method may be called repeatedly; the second and subsequent  calls have no effect.</DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Timer.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Std.&nbsp;Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../java/util/StringTokenizer.html"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../java/util/TimerTask.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="Timer.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: &nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation  contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A.  All Rights Reserved.</font></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -