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

📄 pause.java

📁 JAVA 数学程序库 提供常规的数值计算程序包
💻 JAVA
字号:
package jmathlib.toolbox.time;
   
/* This file is part or MATHLIB */

import jmathlib.core.tokens.*;
import jmathlib.core.tokens.numbertokens.DoubleNumberToken;
import jmathlib.core.functions.ExternalFunction;

/*
Author: Stefan Mueller (stefan@held-mueller.de) 2003
*/

/**wait for a specified period of time*/
public class pause extends ExternalFunction
{

	public OperandToken evaluate(Token[] operands)
	{

        if (getNArgIn(operands) != 1)
			throwMathLibException("pause: number of arguments != 1");
            

		if (operands[0] instanceof DoubleNumberToken) 
        {
			double pause = (((DoubleNumberToken)operands[0]).getReValues()[0][0]);
        
            try {        
                Thread.sleep((int)(pause*1000));
            }
            catch (InterruptedException e)
            {
            }

		}
        
		return null;
	}
}

/*
@GROUP
time
@SYNTAX
pause(value)
@DOC
Wait for a specified period of time. The command pause(n)
waits for n seconds
@EXAMPLES
<programlisting>
pause(3) waits for 3 seconds
pause(3.5) waits for 3.5 seconds
</programlisting>
@NOTES
Keep in mind that the parsing of the pause(x) command will
also take some time. Therefor the  waiting time will be longer
than expected.
@SEE
tic, toc, date, time

*/

⌨️ 快捷键说明

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