package com.flying.promotion.atomic;

import java.util.concurrent.atomic.AtomicBoolean;

/**
 * ???????????????????????????????????????????????boolean????????????????????????????????
 * @author zhongyin.xy
 *
 */
public class AtomicBooleanTest {

	/**
	 * ?????????
	 * @see AtomicBoolean#compareAndSet(boolean, boolean)  ?????????????????????????????????????????????true???????false
	 * @see AtomicBoolean#getAndSet(boolean)   ???????????boolean????????????????????????????
	 */
	public final static AtomicBoolean TEST_BOOLEAN = new AtomicBoolean();
	
	public static void main(String []args) {
		for(int i = 0 ; i < 10 ; i++) {
			new Thread() {
				public void run() {
					try {
						Thread.sleep(1000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					if(TEST_BOOLEAN.compareAndSet(false, true)) {
						System.out.println("???????");
					}
				}
			}.start();
		}
	}
	
} 
