package multithreading;
引入bixteacher的代码作为学习笔记
//至少三条执行路径(三条线程),一条执行路径出问题,不会影响其他执行路径的执行
class Demo extends Thread
{
private String name;
Demo(String name)
{
// super(name);
this.name = name;
}
public void run()
{
int[] arr = new int[3];
System.out.println(arr[3]);//该路径停止执行
for(int x=0; x<10; x++)
{
System.out.println("....x="+x+".....name="+Thread.currentThread().getName());
}
}
}
class ThreadDemo3
{
public static void main(String[] args)
{
Demo d1 = new Demo("旺财");
Demo d2 = new Demo("xiaoqiang");
d1.start();
d2.start();
System.out.println(4/0);//throw new ArithmeticException();即main路径停止执行
for(int x=0; x<20; x++)
{
System.out.println(x+"...."+Thread.currentThread().getName());
}
}
}