Thread与Runnable线程继承与实现

 1 package ThreadL;
 2 
 3 class ThreadR implements Runnable{
 4     static int i=0;
 5     public void run(){
 6         for(int k=0;k<10;i++,k++){
 7             System.out.println("Liang	" + i);
 8         }
 9     }
10 }
11 public class Thread2 {
12     public static void main(String[] args){
13         ThreadR thR = new ThreadR();
14         Thread thT = new Thread(thR);
15         //只是调用ThreadR中覆写的run()方法,但是并不会开启一个线程。
16         thT.run();
17         //重新开启一个线程。同main()函数并发执行。
18         thT.start();
19         for(int i=0;i<10;i++){
20             System.out.println("LiangMengYuan	" + i);
21         }
22     }
23 }
原文地址:https://www.cnblogs.com/zzuLiang/p/4671238.html