线程休眠 sleep(时间)指定当前线程阻塞的毫米值sleep存在异常InterruptedException;sleep时间达到后线程进入就绪状态sleep可以模拟网络延迟(就是在run方法中加一个sleep方法就可以了),倒计时等每一个对象都有一个锁,sleep不会释放锁; package com.Jinone.www; import java.text.SimpleDateFormat; import java.util.Date; public class TextStop { public static void main(String[] args) { //获取当前系统时间 Date date=new Date(System.currentTimeMillis()); while(true) { try { Thread.sleep(1000); //设置显示时间格式 System.out.println(new SimpleDateFormat("yyyy:HH:mm:ss").format(date)); //更新当前时间 date=new Date(System.currentTimeMillis()); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } public static void tenDown() { int num=10; while(true) { try { Thread.sleep(1000); System.out.println(num--); if(num<=0) { break; } } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }