1 package multithread;
2
3 class Demo extends Thread{
4 private String name;
5 Demo(String name){
6 this.name=name;
7 }
8 public void run() {
9 int[] arr = new int[3];
10 System.out.println(arr[3]);
11 for (int x = 0; x < 10; x++) {
12 System.out.println("....x="+x+"....name="+Thread.currentThread());
13 }
14 }
15 }
16
17 public class ThreadDemo3 {
18
19 public static void main(String[] args) {
20 // TODO Auto-generated method stub
21 Demo d1 = new Demo("旺财");
22 Demo d2 = new Demo("xiaoqiang");
23 d1.start();
24 d2.start();
25
26 System.out.println(4/0);//throw new ArithmeticException
27 for (int x = 0; x < 20; x++) {
28 System.out.println(x+"...."+Thread.currentThread().getName());
29 }
30 }
31
32 }