본문 바로가기

IT/혼자공부하기

extends Thread

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package study;
 
public class Thread1 extends Thread {
 
    String t;
    
    public Thread1(String arg0) {
        this.t = arg0;
    }
    
    @Override
    public void run() {
        System.out.println("테스트");
        
        while (true) {
            try {
                sleep(2000);
                System.out.println("while문 안에 있는 출력문");
            } catch (InterruptedException e) {
                // TODO 자동 생성된 catch 블록
                e.printStackTrace();
            }
        }
    }
 
 
 
    public static void main(String[] args) {
        Thread1 t1 = new Thread1("호출");
        t1.start();
 
    }
 
}
 
cs


'IT > 혼자공부하기' 카테고리의 다른 글

키 테스트  (0) 2018.05.27
Block 방식 Thread  (0) 2018.05.17
Implement Runnable 방식  (0) 2018.05.17
switch 문  (0) 2018.04.28
자료형  (0) 2018.04.19