1 package multithread4;
2
3
4 /*
5 class Test implements Runnable{
6 public void run(Thread t) {
7
8 }
9 }*/
10 //如果错误,错误发生在哪一行,错误在第一行,应该被abstract修饰 run方法没被覆盖,
11 public class ThreadTest {
12
13 public static void main(String[] args) {
14 // TODO Auto-generated method stub
15 new Thread(new Runnable() {
16
17 @Override
18 public void run() {
19 System.out.println("runnable run");
20
21 }
22 }) {
23 public void run() {
24 System.out.println("subThread run");//以子类为主 输出subThread run
25 }
26 }.start();
27 /*new Thread() {
28 public void run() {
29 for (int x = 0; x < 50; x++) {
30 System.out.println(Thread.currentThread().getName()+"x="+x);
31 }
32 }
33 }.start();
34
35 for (int x = 0; x < 50; x++) {
36 System.out.println("y="+x);
37 }
38 Runnable r = new Runnable() {
39
40 @Override
41 public void run() {
42 for (int x = 0; x < 50; x++) {
43 System.out.println(Thread.currentThread().getName()+"z="+x);
44 }
45 }
46 };
47 new Thread(r).start();
48 */
49 }
50
51 }