작성
·
29
0
문제와풀이 마지막문제인데요
package thread.test;
import static thread.util.MyLogger.log;
public class StartTest4Main {
public static void main(String[] args) {
Runnable runnable1 = new Runnable() {
@Override
public void run() {
log("A");
}
};
Runnable runnable2 = new Runnable() {
@Override
public void run() {
log("B");
}
};
for (; ; ) {
Thread threadA = new Thread(runnable1);
threadA.setName("Thread-A");
threadA.start();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Thread threadB = new Thread(runnable2);
threadB.setName("Thread-B");
threadB.start();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
}
저는 코드를 이렇게 구현했는데 틀린걸까요?
답변