package com.torrise.rabbit;
public class Torrise implements Runnable{
@Override
public void run() {
int len=0;
while (len<100) {
len+=5;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print("乌龟跑了"+len+"米\n");
}
}
public class Torrise implements Runnable{
@Override
public void run() {
int len=0;
while (len<100) {
len+=5;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print("乌龟跑了"+len+"米\n");
}
}
}
package com.torrise.rabbit;
public class Rabbit implements Runnable{
@Override
public void run() {
int len=0;
while (len<100) {
len+=10;
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print("兔子跑了"+len+"米\n");
}
}
}
package com.torrise.rabbit;
public class main {
/**
* @param args
*/
public static void main(String[] args) {
Torrise torrise=new Torrise();
Rabbit rabbit=new Rabbit();
Thread thread1=new Thread(torrise);
Thread thread2=new Thread(rabbit);
thread1.start();
thread2.start();
}
}