package com.basic;//Thread Priority이용하여 우선순위 높이기
public class ThreadEx9 {
public static void main(String[] args){
ThreadEx9_1 th1 = new ThreadEx9_1();
ThreadEx9_2 th2 = new ThreadEx9_2();
//우선순위를 기본우선순위(5) - > 7
th2.setPriority(7);
System.out.println("Priority of th1(-) : "+th1.getPriority());
System.out.println("Priority of th2(|) : "+th2.getPriority());
th1.start();
th2.start();
}
}
class ThreadEx9_1 extends Thread{
public void run(){
for(int i=0;i<300;i++)
System.out.print("-");
}
}
class ThreadEx9_2 extends Thread{
public void run(){
for(int i=0;i<300;i++)
System.out.print("|");
}
}Priority of th1(-) : 5
Priority of th2(|) : 7
---------------|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||-----------------------------------------------||||||||||||||||-|----||||||||
||||||||||---------|||||||||||||||||-|||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||-----------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
----------------------------------------
'Java > Thread' 카테고리의 다른 글
| swing으로 디지털 시계 만들기 (1) | 2012.04.11 |
|---|---|
| Thread synchronization(스레드 동기화) (0) | 2012.04.11 |
| Multi-Thread (0) | 2012.04.11 |
| Thread runnable (0) | 2012.04.11 |
| Thread(스레드,쓰레드) (0) | 2012.04.11 |