public class ImplementsRunnable {
public static void main(String[] args) {
Runnable r1 = new c3();
Runnable r2 = new c4();
Thread t1 = new Thread(r1);
Thread t2 = new Thread(r2);
t1.start();
t2.start();
}
}
class c3 implements Runnable{
@Override
public void run() {
for (int i = 0; i < 1000; i++) {
System.out.println("who are you ?");
}
}
}
class c4 implements Runnable{
@Override
public void run() {
for (int i = 0; i < 1000; i++) {
System.out.println("i am li lei");
}
}
}
实现Runnable 实现线程
最新推荐文章于 2024-09-02 20:59:26 发布