标签:ica 实现 多线程 log nbsp super ges es2017 .text
第一种 继承Thread类
import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; /** * Created by meicai on 2017/3/17. */ public class Hello { public static void main(String [] args) { System.out.println("begin|线程名:"+Thread.currentThread().getName()); Person p1=new Person("曹慧明"); p1.start(); Person p2=new Person("wt"); p2.start(); System.out.println("end|线程名:"+Thread.currentThread().getName()); } } /** * 多线程 * 1.继承Tread类 * 2.重写run方法 * 3.调用start方法 */ class Person extends Thread { private String name; public Person (String name){ super(name);//给线程起名字 this.name=name; } public void run(){ show(this.name); } public void show(String name){ SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); for(int i=0;i<10;i++) { System.out.println(name+i + sdf.format(new Date())+"|线程名:"+getName()); } } }
标签:ica 实现 多线程 log nbsp super ges es2017 .text
原文地址:http://www.cnblogs.com/caohuimingfa/p/7639865.html