package com.homework;
public class Test {
public static void main(String[] args) {
String []names=new String[]{"a","b","c","d","e","f","g","h","i","j"};
for (int i = 0; i <10; i++) {
new Thread(new Runnable(){
@Override
public void run() {
thougthCave();
}
},names[i]).start();
}
}
public static synchronized void thougthCave(){
System.out.println(Thread.currentThread().getName()+"通过山洞");
}
}
package com.homework;
public class TestThread {
public static void main(String[] args) {
Thread t = new Thread();
System.out.println(t.isAlive());
t.start();
System.out.println(t.isAlive());
t.interrupt();
System.out.println(t.isAlive());
}
}