阅读背景:

java并发(二)对象的共享-可见性

来源:互联网 

public class NoVisibility {
	private static boolean ready;
	
	private static int number;
	
	private static class ReaderThread extends Thread{
		public void run(){
			while(!ready){
				Thread.yield();
				System.out.println(number);
			}
		}//end run()
	}//end Class ReaderThread

	public static void main(String[] args){
		new ReaderThread().start();
		number = 42;
		ready = true;
	}
}


public class NoVisibility {
	private static boo




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: