Created
March 23, 2021 04:54
-
-
Save accidentlywoo/bfca35138b40cf3022609231ab36841a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ThreadTest implements Runnable{ | |
public ThreadTest(){ } | |
public void run(){ | |
System.out.println(Thread.currentThread().getName()+" : Thread Start."); | |
for (int i = 0; i < 10; i++){ | |
try { | |
Thread.sleep(1000); | |
System.out.println(i+1+"초"); | |
}catch (Exception e){ | |
e.printStackTrace(); | |
} | |
} | |
System.out.println(Thread.currentThread().getName()+" : Thread End."); | |
} | |
public static void main(String[] args) { | |
Thread thread = new Thread(new ThreadTest()); | |
thread.start(); | |
System.out.println("Thread가 종료될때까지 기다립니다."); | |
try{ | |
thread.join(); | |
}catch (InterruptedException e){ | |
e.printStackTrace(); | |
} | |
System.out.println("Main Thread End"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment