10.쓰레드 2017-08-09 Java MultiThreadEx.java12345678910111213141516171819202122232425public class MultiThreadEx { public static void main(String[] args) { Thread thread1 = new AlphabetThread(); //쓰레드 생성방법1 Thread thread2 = new Thread( new DigitThread()); //쓰레드 생성방법2 //매개변수로 Runnable이 구현된 객체를 받음 new Thread( new Runnable() { //쓰레드 생성방법3 @Override public void run() { for( char c = 'A'; c<= 'z'; c++) { System.out.print( c ); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }).start();; thread1.start(); thread2.start(); }} DigitThread.java12345678910111213public class DigitThread implements Runnable{ public void run() { for(int i = 0; i < 10; i++) { System.out.print( i ); try { Thread.sleep( 1000 ); } catch (InterruptedException e) { e.printStackTrace(); } } }} AlphabetThread.java1234567891011121314public class AlphabetThread extends Thread{ @Override public void run() { for( char c = 'a'; c <= 'z'; c++) { System.out.print( c ); try { Thread.sleep( 1000 ); } catch (InterruptedException e) { e.printStackTrace(); } } }}