java多线程 用匿名内部类创建多线程

实现Runnable接口

new Thread(new Runnable(){
	public void run(){
		System.out.println("thread is running");
	}
}).start();

或继承Thread类

new Thread(){
	public void run(){
		System.out.println("thread is running");
	}
}.start();

猜你喜欢

转载自oracle-api.iteye.com/blog/2382460