반응형
Thread 예제
class SimpleThread extends Thread{
String msg;
public SimpleThread(String msg) {
this.msg = msg;
}
public void run(){
for(int i=1;i<=10;i++){
System.out.println(i+"번째 출력 "+msg);
}
}
}
public class ThreadTest1 {
public static void main(String[] args) {
SimpleThread st1 = new SimpleThread("One");
SimpleThread st2 = new SimpleThread("Two");
SimpleThread st3 = new SimpleThread("Three");
st1.start(); // 멀티스레드 방식
st2.start();
st3.start();
st1.run(); // 싱글스레드 방식
st2.run();
st3.run();
}
}
반응형
'콩's EDUCATION > 콩's JAVA_RUN' 카테고리의 다른 글
Join (0) | 2014.05.21 |
---|---|
Runnable (0) | 2014.05.21 |
Java 문제 7 (0) | 2014.05.20 |
Java 문제 6 (0) | 2014.05.20 |
SimpleDateFormat (0) | 2014.05.20 |