🍺JAVA

[JAVA] 쓰레드를 이용한 주사위게임~

김말자 2022. 12. 29. 17:46
728x90
728x90
BIG

 

public class ThreadSleep {
	public static void main(String[] args) {
		int d1, d2;
		
		final int DELAY_TIME = 1000;
		Random ra = new Random();
		
		d1=ra.nextInt(6)+1;
		for(int i=0; i<10;i++) {
			System.out.print(".");
			try {
				Thread.sleep(DELAY_TIME); //반드시 오류처리해줘야됨
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		System.out.println("1번주사위"+d1);
		d2=ra.nextInt(6)+1;
		for(int i=0; i<10;i++) {
		System.out.print(".");
		try {
			Thread.sleep(DELAY_TIME); //반드시 오류처리해줘야됨
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}}
	
	System.out.println("2번주사위"+d2);

	
	}

728x90
반응형
BIG