Java/Excercise

thread ch01 MyThreadEx3

낭구리 2021. 9. 7. 17:46
package ch01;

class MyThread extends Thread{
	@Override
	public void run() {
		for (int i = 0; i < 20; i++) {
			System.out.println(i + " : " + Thread.currentThread());
		}
	}
}

public class MyThreadEx3 {

	public static void main(String[] args) {
//		문제 1 쓰레드 3개 생성
		//쓰레드 start() 호출
		
		MyThread  thread1 = new MyThread();
		MyThread  thread2 = new MyThread();
		MyThread  thread3 = new MyThread();

		thread1.start();
		thread2.start();
		thread3.start();
	}

}

'Java > Excercise' 카테고리의 다른 글

thread ch01 ThreadTest3  (0) 2021.09.08
swing ch04 집만들기  (0) 2021.09.07
thread ch01 ThreadTest2  (0) 2021.09.07
thread ch01 ThreadTest1  (0) 2021.09.07
swing ch05 EventListenerEx9  (0) 2021.09.07