为什么执行结果不是两个线程一起执行啊?- new Thread(
- new Runnable(){
- public void run(){
- while(true){
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println("Runnable"+Thread.currentThread().getName());
- }
- }
- }
- ){
- public void run(){
- while(true){
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println("子类"+Thread.currentThread().getName());
- }
- }
- }.start();
- }
- }
复制代码 |
|