标签:color ati tar div this run art thread style
1 package MyThread; 2 import java.lang.*; 3 public class MyThread extends Thread{ 4 private String name; 5 public MyThread(String name){ 6 this.name = name; 7 } 8 public void run(){ 9 10 for(int i=0;i<5;i++){ 11 System.out.println(name+i); 12 } 13 } 14 public static void main(String[] args) { 15 16 17 } 18 19 }
1 package MyThread; 2 3 public class ThreadTest { 4 5 public static void main(String[] args) { 6 MyThread t1 = new MyThread("线程A"); 7 MyThread t2 = new MyThread("线程B"); 8 9 t1.start(); 10 t2.start(); 11 12 for(int i=0;i<5;i++){ 13 System.out.println("主线程"+i); 14 } 15 16 17 } 18 19 }
标签:color ati tar div this run art thread style
原文地址:http://www.cnblogs.com/the-wang/p/6752991.html