读书人

线程容易实例

发布时间: 2012-11-09 10:18:48 作者: rapoo

线程简单实例

线程简单实例

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();}}}

?

读书人网 >编程

热点推荐