Skip to Content
Suffering builds character
아카이브13.프로세스,스레드특징프로세스와 스레드1. 순차 처리하기

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