java
extends Thread ¥µ¥ó¥×¥ë †
class MyThread1 extends Thread {
public void run() {
for (int i = 1; i <= 10 ; i++) {
try {
sleep(500);
System.out.println("foo");
} catch (InterruptedException e) {
}
}
}
}
class MyThread2 extends Thread {
public void run() {
for (int i = 1; i <= 10 ; i++) {
try {
sleep(1000);
System.out.println("bar");
} catch (InterruptedException e) {
}
}
}
}
class test {
public static void main(String[] args) {
MyThread1 t1 = new MyThread1();
MyThread2 t2 = new MyThread2();
t1.start();
t2.start();
}
}