package app;
public class threadTest {
public static void main(String[] args) {
person pp = new person();
for(int i = 0;i<10;i++){
new Thread(pp).start();
}
}
}
class person implements Runnable {
@Override
public void run() {
thought();
}
public synchronized void thought(){
try {
System.out.println(Thread.currentThread().getName()+"通过山洞");
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}