画坦克__线程__V1__第一种方法创造线程

一、代码如下

package www.tainiu.gui__V2;

public class aa__XianCheng__V1 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Cat cat1= new Cat();
		Cat cat2= new Cat();
		cat1.start();
		cat2.start();

	}

}



class Cat extends Thread{
	int times= 0;
	@Override
	public void run() {
		// TODO Auto-generated method stub
		super.run();
		while(true) {
			try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
			times ++;
			System.out.println("Hello World__"+times+this.getName());
			if(times == 10) {
				break;
			}
		}
		
		
	}
}
原文地址:https://www.cnblogs.com/wujianbo123/p/7633092.html