Java中的线程的休眠Thread.sleep()

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/itpinpai/article/details/8462432
class MyThead implements Runnable
{
	public void run()
	{
		System.out.println("我休息了!");
		try
		{
			Thread.sleep(1000);
		}
		catch (InterruptedException e)
		{
		}
		System.out.println("一秒后在叫我吧!");
	}
}

public class TheadMain
{
	public static void main(String[] args)
	{
		MyThead myThead = new MyThead();
		Thread thread = new Thread(myThead);
		thread.start();
	}
}

展开阅读全文

没有更多推荐了,返回首页