class ThreadSchedule extends Thread
{
static boolean doYield = false;
public ThreadSchedule( String name ) {
super(name);
}
public void run() {
while(true) {
System.out.println( getName() );
if (doYield) yield();
}
}
public static void main(String[] args) {
if (args.length > 0)
ThreadSchedule.doYield = true;
ThreadSchedule thread1 = new ThreadSchedule("thread1");
ThreadSchedule thread2 = new ThreadSchedule("thread2");
thread1.start();
thread2.start();
}
댓글 없음:
댓글 쓰기