62,615
社区成员
发帖
与我相关
我的任务
分享
class ThreadAndRunnable implements Runnable {
private int x = 0;
public void run() {
System.out.println(++x);
}
}
public class Test {
public static void main(String[] args){
ThreadAndRunnable r = new ThreadAndRunnable();
for (int i = 0; i < 10; i++) {
Thread t = new Thread(r);
t.start();
}
}
}
class ThreadAndRunnable extends Thread {
private static int x = 0;
public void run() {
System.out.println(++x);
}
}
public class Test {
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
Thread t = new ThreadAndRunnable();
t.start();
}
}
}