import java.lang.*;
import java.util.Date;public class test
{
public static void main(String[] args)
{
Runner r=new Runner();
Thread t=new Thread(r);
t.start();
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
t.interrupt();
}
}class Runner implements Runnable
{
public void run()
{
while(true){
System.out.println("==========" +new Date()+"==========");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
return ;
}
}
}
}为什么Thread没有实例化就可以执行Thread.sleep(10000);
解决方案 »
- 求电子版Thinking in Java e3
- 请教高手正规表达式
- 关于Integer.parseInt()的问题???
- 有关计算数学常数e的一个问题?
- 我今天刚去应聘的一道笔试题,帮我分析一下?
- 请教一下关于位操作在JAVA里的应用,一直不太明白这个,请问在JAVA中位操作都有哪些应用呢?最好有例子,不胜感激!
- 有关private的用法
- 如何对字符串进行扫描,然后提取相关信息!
- 请教各位一个有关DataStream中的一些问题!!!
- :请问:高手请进来:在midp中如何访问手机的内部文件呀“例如:通讯录”,最好有例子呀!!!!一片绿叶在吗??????!!!!!!
- 请假构造方法里面同时出现this(),与super()问题
- 初学java,求java基础与案例开发详解 张孝全 pdf电子书
* Causes the currently executing thread to sleep (temporarily cease
* execution) for the specified number of milliseconds, subject to
* the precision and accuracy of system timers and schedulers. The thread
* does not lose ownership of any monitors.
*
* @param millis the length of time to sleep in milliseconds.
* @exception InterruptedException if any thread has interrupted
* the current thread. The <i>interrupted status</i> of the
* current thread is cleared when this exception is thrown.
* @see Object#notify()
*/
public static native void sleep(long millis) throws InterruptedException;就像String.valueOf