단일 쓰레드 : 프로세스의 특정한 수행 경로
멀티 쓰레드 :하나의 프로세스를 동시에 처리하는 것처럼 보이지만 매우 짧은 단위로 분할해서 차례로 처리한다. (병렬적) 한 개의 처리경로를 여러 개로 나누어 동시 작업이 가능하다.
ex) JSP웹페이지 - 멀티 스레드 응용 프로그램
public class Animals extends Thread {
private String sounds;
public Animals() {
;
}
public Animals(String sounds) {
this.sounds = sounds;
}
public void run() {
printSound(500);
}
private void printSound(long millis) {
for (int i = 0; i < 10; i++) {
System.out.println(sounds);
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}