Java(三)并发控制12.线程睡眠

使用sleep可以使线程暂停

public class SleepDemo {
	public static void main(String[] args) throws InterruptedException
	{
		for(int i=10;i>0;i--)
		{
			System.out.println("还剩"+i+"秒");
			Thread.sleep(1000);
		}
		System.out.println("爆炸");
	}
}

在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_37282683/article/details/82870033
今日推荐