1. 순차 처리하기
다음은 순차적으로 처리되는 코드의 예시로,
만약 a()가 작업을 처리하는데 오랜 시간이 소요될 경우,
b()는 a()가 작업을 완료할 때까지 기다려야 함
Main.java
public class Main {
public static void main(String[] args) {
a();
b(); // a()가 끝나야 실행됨
c(); // b()가 끝나야 실행됨
}
static void a() {
System.out.println("a() started");
// 오래 걸리는 작업..(ex. 3초 이상)
while (true) {
}
}
static void b() {
System.out.println("b() called");
}
static void c() {
System.out.println("c() called");
}
}Last updated on