`

线程简单实例

阅读更多

线程简单实例

public class Main extends Thread{
	public static void main(String[] args) {
		//每隔3秒执行一次这个线程
		/*while (true) {
			try {
				Thread.sleep(3000);
				System.out.println("this is thread1");
			} catch (InterruptedException ex) {
				e.printStackTrace();
			}
		}*/
		
//		3秒以后执行次线程
		try {
			Thread.sleep(3000);
			System.out.println("3秒后执行此线程");
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
	}
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics