Java多线程____线程yield方法介绍

package com.test.thread;


public class TestYield {
	public static void main(String[] args) {
		TestThread t1 = new TestThread("A_01");
		TestThread t2 = new TestThread("B_02");
		t1.start();
		t2.start();
	}
}

class TestThread extends Thread {
	public TestThread(String name) {
		super(name);
	}
	public synchronized void run() {
		for (int i = 0; i < 10; i++) {
			System.out.println(Thread.currentThread().getName());
			//Thread.yield();
		}
		
	}
}

posted @ 2017-07-12 16:52  蜜獾互联网  阅读(2)  评论(0编辑  收藏  举报  来源