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 36 37 38 39 40 41 | package study; //인터페이스 스레드( Runnable ) public class ImplementThread implements Runnable { String v; public ImplementThread() { // TODO 자동 생성된 생성자 스텁 } public ImplementThread(String v) { this.v = v; } @Override public void run() { // TODO 자동 생성된 메소드 스텁 while (true) { try { Thread.sleep(300); System.out.println(" 수영이와 소영이 둘 중에 한 명이 반장되야한다. "); System.out.println(Thread.currentThread().getName()); } catch (InterruptedException e) { // TODO 자동 생성된 catch 블록 e.printStackTrace(); } } } public static void main(String[] args) { ImplementThread im = new ImplementThread(); Thread t = new Thread(im); t.start(); } } | cs |
'IT > 혼자공부하기' 카테고리의 다른 글
키 테스트 (0) | 2018.05.27 |
---|---|
Block 방식 Thread (0) | 2018.05.17 |
extends Thread (0) | 2018.05.17 |
switch 문 (0) | 2018.04.28 |
자료형 (0) | 2018.04.19 |